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
Post a Comment