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

android - questions about switching from C2DM to GCM -

c++ - Qt setGeometry: Unable to set geometry -

batch file - How to extract all multi-volume RAR archives from subfolders of a folder? -