This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

I have a bug

This is my problem. The answer is 0-AAAA.
#include <stdio.h>
#include <string.h>
int main(int argc,char*argv[]){
int i=1;
char buf[4];
strcpy(buf,"AAAA");
printf("%d-%s\n",i,buf);
return 0;
}

I increased the size of buffer buf[5] and the answer is 1-AAAA. Is this the best solution?
Could you explain me why I have this answer, because I'm new in C/C++?

0