04-24-2011, 04:55 PM
Dear student!
You should check initialization of array. String array can be initialised at the time of declaration just as other variables are initialised. For example:
char s1[] = "example";
char s2[20] = "another example" would store the two strings as follows:
s1 |e|x|a|m|p|l|e|\0|
s2 |a|n|o|t|h|e|r| |e|x|a|m|p|l|e|\0|?|?|?|?|
You should check initialization of array. String array can be initialised at the time of declaration just as other variables are initialised. For example:
char s1[] = "example";
char s2[20] = "another example" would store the two strings as follows:
s1 |e|x|a|m|p|l|e|\0|
s2 |a|n|o|t|h|e|r| |e|x|a|m|p|l|e|\0|?|?|?|?|
