I wrote a c code like this:
#include <stdio.h>
#include <stdlib.h>
int main()
{
char* string;
char n;
while(scanf("%s",string)!=EOF){
printf("\n%s\n",string);
}
return 0;
}
it shows an error by keep printing null. However it works when I change the
char* string;
into
char string[50];
What is the reason behind this?
The char string[n] is able to reprint whatever I write on the terminal