I want to write a C program that stores a bunch of sentences while it's running and prints them out at the end of the program. Here's what I wrote:
#include<string.h>
#include<stdio.h>
int main(){
int counter = 0;
char state[100][200];
char stroo[3] = "yes";
sprintf(state[counter], "%s", stroo);
counter++;
char poo[2] = "44";
sprintf(state[counter], "%s", poo);
counter++;
for (int i=0; i<counter; i++) {
printf("%s\n", state[i]);
}
return 0;
}
For the output, the first line prints "yes" which is what I expected. The second line, however, prints "44yes". Why is it printing "yes" as well as "44"?