c - Strings - Data Type -


i have learned how handle data types except, strings. so, can me strings?

in declaration

char surnm[4] = {'p', 'i', 'n', 'e', '\0'}; 

there 5 initializers 4 elements in array surnm. array not contain string because did not included terminating zero. should write either

char surnm[5] = {'p', 'i', 'n', 'e', '\0'}; 

or

char surnm[] = {'p', 'i', 'n', 'e', '\0'}; 

or

char surnm[5] = { "pine" }; 

or

char surnm[5] = "pine"; 

or

char surnm[] = { "pine" }; 

or

char surnm[] = "pine"; 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -