The code is asking the user for input. The input will then be converted to a int however I am getting a seg fault pointing to Line:12 fgets(userInput, 2, stdin). Why is it so?
#include <stdio.h>
#include <stdlib.h>
int main() {
// Write C code here
char *userInput;
int userChoice;
printf("No: ");
int c;
fgets(userInput, 2, stdin);
while ((c = fgetc(stdin)) != '\n' && c != EOF);
userChoice = atoi(userInput);
return 0;
}