I'm trying to use fgets to get a line from stdin. Here's my code
char* FENString;
printf("Enter FEN Key: ");
fgets(FENString, 50, stdin);
FENString only has one char, and that's the new line character. I've tried looking for help and haven't found anything, does anyone know why this is happening?
It's very important to make sure that all variables have some sort of memory allocated to it, at least in some point of its lifecycle. The issue here was that the char pointer didn't have any sort of memory allocated to it. Something that could've fixed it is malloc
ing the FENString, or perhaps changing the declaration to something like char FENString[50];