There is another question I want to ask about the fgets() in C. Here is my code
Code:
#include <string.h>
#include <stdio.h>
1.int main (int argc, char *argv[]){
2. char* input;
3. char* arg;
4. fgets ( input ,43, stdin ) ;
5. arg = strtok(input," ");
6. printf("%s\n",arg);
7.}
After compiling and executing the code, I got the error
Code:
red 313 % input.out
input from the screen
Segmentation fault
I thought it is gonna print out
Code:
input
from
the
screen
but it did not. I need an explanation for it