something strange happens in my code.
I'm using fgets
to get each line of a file and then I use strtok
to parse it. using Ubuntu, if I compile using gcc -o name name.c
, it gives me segmentation fault
. If I compile using -fsanitize=address
, the code runs perfectly without any segv. What could be the problem?
the code is:
char* input;
fgets(input, 1000, stdin);
tok=strtok(input, pars);
but it looks like it stops at fgets
.