Hi,
I'm pretty new to C programming, so bear with me if this has a simple answer.
I have an error that seems very strange to me. The following code when run produces an error and crashes.
The strange thing is that if i get rid of theCode:#include <stdio.h> #include <string.h> int main () { int i; char *str; gets(str); return 0; }or if i put theCode:int i;after theCode:int i;there is no error. Also, theCode:char *str;can be replaced by an analogous scanf function and the same error results. The same error also results when using a double, float, char etc... instead of an int.Code:gets(str);
However, when I declare str asfor example, there is no error.Code:char str[4];
Any ideas?
Thanks for your help.