Just a tiny correction in John's example (which isn't wrong! just redundant)... This:
Will fill the entire array with zeros, but this:Code:char s[SIZE + 1] = { 0 };
Will fill the array again, this time, with spaces.Code:memset( s, ' ', SIZE );
The compiler will not "optimize" this. The faster code should be:
PS: And his solution using macros is very nice!Code:char s[SIZE + 1]; // no initializer memset( s, ' ', SIZE ); s[SIZE] = '\0'; s[0] = 'x'; s[SIZE - 1] = 'y';
[]s
Fred