That's interesting. Try the code below and see if you get a seg fault:
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
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.
fgets(str, sizeof str, stdin);