Very odd segmentation fault/core dump.
So I'm pulling out my hair here, as I can't figure this out. I'm getting a segmentation fault ( core dump) in my program and I don't understand why. It's a clean compile and when I run the program and it asks me for a valid choice, the scanf statement causes the seg fault. The code is below, but I'm totally baffled here.
Code:
void MenuOne ( int numStrings, char **strArray )
{
int i, inc = 1, userInput = 1, constant = 5;
printf("\nMenuOne function opened. %d\n", numStrings );
for ( i = 0; i < numStrings; i++ )
{
printf("strArray[%2d] - %s\n", i, strArray[i] );
}
printf ("Please select which string you'd like to analyze, or 0 to quit.\n");
scanf ("%d", &userInput );
printf("%d is the user's input\n", userInput);
while( userInput < 0 || userInput > numStrings )
{
fprintf(stderr, "\nPlease enter a valid response. " );
scanf("%d", &userInput );
}
MenuTwo ( userInput, strArray );
}