Initialization of a String
The declaration
char stooge3[6]="Larry";
is equivalent to
char stooge3[6];
stooge3[0] = 'L';
stooge3[1] = 'a';
stooge3[2] = 'r';
stooge3[3] = 'r';
stooge3[4] = 'y';
stooge3[5] = '\0';
Try to use stooge3[6] in an expression is a serious programming error.
Previous slide
Next slide
Back to first slide
View graphic version