I wrote this C code:
#include<stdio.h>
#include<string.h>
int main()
{
char *i, *p, *p1="Hello";
strcpy(p,p1); //The first strcpy works.
printf("%s\n", p); //show copy successful
printf("Please hit a key to continue....\n");
getchar();
strcpy(i,p); //The second strcpy causes stop working problem. Why?
printf("%s\n", i);
return 0;
}
Can anyone tell me why the second strcpy
doesn't work?