So now I've got a new problem. I've adjusted my code according to a FAQ. It is now
Code:
void find_subject( int **crns, char ***subjects, char ***courses,
int *count )
{
char input[4], str[4];
int i, j;
while (( i = getchar()) != '\n' && i != EOF);
printf("Please enter a subject: ");
if (fgets(input, 4, stdin))
{
for ( j = 0 ; j <= *count ; j++ )
{
strcpy(str, (*subjects)[j] );
if ( str == input )
printf("%i %s %s\n", (*crns)[j], (*subjects)[j], (*courses)[j]);
}
}
printf("\n");
}
The problem is, I have an infinite loop. gdb shows that thing cycles endlessly between the for loop and strcpy. It never reaches the if statement. Why?