DEV Community

Discussion on: String in C Programming

Collapse
dynamicsquid profile image
DynamicSquid • Edited on
char myArray[4] = {'A', 'L', 'I', 'M', 'A', 'M'};
Enter fullscreen mode Exit fullscreen mode

That's not good. The array has size 7 but you only set the array to 4.

Also in your example you could have printed out the string using formatting like this:

printf("\n Answer is : %s", answer);
Enter fullscreen mode Exit fullscreen mode