Hey guys,
I'm working on a project for my programming class, and for the part I'm working on, I ask the user if they want to repeat the sequence again or return to the menu. If the user enters 1 it will repeat the sequence, if 0, it will return to the menu. However, for some reason it will not read 0 when I type it in. If I type 1, everything works fine, it just doesn't seem to like the 0. I have the sort of code for a different function and everything works fine, I have no idea what's going on here, and it's really bugging me, maybe you can help.
This is the error:
Type 1 to return to the search or 0 to return to the drill database.
0
Program received signal: “EXC_BAD_ACCESS”.
sharedlibrary apply-load-rules all
warning: Unable to read symbols for "" (file not found).
warning: Unable to read symbols from "" (not yet mapped into memory).
And this is the code for the function:
Code:
int drill_search(void)
{
int choice, i, j, wtf;
char drill[SIZE][SIZE];
char garbage[2];
printf("Enter the critera for your search:\n");
printf("1. Title of drill\n");
printf("2. Muscles worked\n");
printf("3. Strokes used\n");
scanf("%d", &choice);
do {
switch (choice) {
case 1:
printf("Enter the name of the drill:\n");
fgets(garbage, 2, stdin);
fgets(drill[0],50,stdin);
if (drill[0][strlen(drill[0])-1]=='\n')
drill[0][strlen(drill[0])-1]='\0';
drill_info(drill, choice);
/* resets the array */
for (i=0; i< SIZE; i++) {
garbage[i]='\0';
for (j=0; j<SIZE; j++)
drill[i][j]='\0';
}
break;
case 2:
printf("2");
break;
case 3:
printf("3");
break;
default:
return(1);
choice = 1;
break;
}
printf("Type 1 to return to the search or 0 to return to the drill database.\n");
scanf("%d", &wtf);
if (wtf == 0)
return 1;
} while (wtf == 1);
return(0);
}
The bold is what I'm having trouble with.