Exit status -1
This is my code and I am not getting why is it showing exit status -1.
scanf("%s",c); //to take in the 1st string
scanf("%c",&d);//after string the newline char needs to get in the buffer
scanf("%s",e); //to take in another string
printf("%s\n%s",c,e); //to print both the strings
The only thing that's allocated for pointers up front:
char *c;is the address for the variable 'c' itself.
What 'c' is currently pointing at...who knows. For the sake of deterministic behavior, it may be a good idea to initialize it to
char *c = NULL; scanf("%s", c); // bad! writing to NULL
char *c = NULL; c = (char*)malloc(sizeof(char) * 20); // make space first scanf("%s", c); // now I can write to 'c'