Hello,
I need a little help.
This code works without any errors.
the codes stop working and I get a "Segmentation fault" announcement.Code:int main() { int i=0; char c=0; char *command; while ((c=getchar()) != '\n'){ command[i]=c; i++; } command[i]='\0'; return 1; } However, when I add a new variable, for example: int main() { int i=0, k=0; char c=0; char *command; while ((c=getchar()) != '\n'){ command[i]=c; i++; } command[i]='\0'; printf(" k is %d\n", k+3);[/B] return 1; }
What is the problem?
Thanks



LinkBack URL
About LinkBacks



