G
Gary
When you declare an array of chars and store a string in it, where is
the position of the null character \0? And what happens to the unused
memory locations?
#include <stdio.h>
int main(void)
{
char gstring2[25] = "dudes";
gstring2[5] = 'a';
printf("%s \n", gstring2);
return 0;
}
The output of main function was
dudesa
How come this code works, and the statement
gstring2[5] = 'a';
doesn't overwrite the null character?
the position of the null character \0? And what happens to the unused
memory locations?
#include <stdio.h>
int main(void)
{
char gstring2[25] = "dudes";
gstring2[5] = 'a';
printf("%s \n", gstring2);
return 0;
}
The output of main function was
dudesa
How come this code works, and the statement
gstring2[5] = 'a';
doesn't overwrite the null character?