Well i didn't consider further code important because i had already
used a printf("test") statement immediately after fgets & it's not
getting executed. I get seg fault eror the instant i hit the enter
key.
That's interesting. Try the code below and see if you get a seg fault:
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void)
{
char str[50];
printf("Enter string:\n");
fgets(str, sizeof str, stdin);
printf("%s\n", str);
return 0;
}
If you do not get a seg fault, then something else must be wrong with your original code, so you should post the smallest and simplest program that demonstrates the error.