Hey Everyone.
I am slightly stuck in writing this code and would appreciate any help.
This is only the start of the actual the program. The program is menu driven, the first menu gives the user 2 options to either open a file or exit the program. If option 1, open a file is entered then the user needs to input the file name. If correct its meant to display another menu but if its incorrect then its meant to display that the file cannot be found and then display the first menu again.
This is what I have so far, Im just not sure how to go back to the first menu after an incorrect file name is inputted and also how to go to the next menu if it is correct.
Any help would be great.Code:#include <stdio.h> int main() { int d; printf("\n\n\t\tMenu:\n"); printf("\n\n\t\t[1] Open a File (Supported .grc)\n"); printf("\t\t[2] Exit\n"); printf("\n\n\t\tPlease Select and Option [1 or 2]:"); scanf("%d", &d); switch(d) { case 1: { FILE *fp; char fname[100]=""; printf("\n\tEnter File Name:"); scanf("%s",&fname); fp=fopen(fname,"rb"); if(fp==NULL) { printf("\n%s\" File Not Found!",fname); getch(); } { case 2: exit(0); } return 0; } }}
Thanks



1Likes
LinkBack URL
About LinkBacks



