Return back to main function (Need help)

Hi. i tried to write a program like this.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <stdio.h>
#include <conio.h>
int fFileMenu(){
    printf("This is file menu");
}
int fEditMenu(){
    printf("This is edit menu");
}
int fViewMenu(){
    printf("This is view menu");
}
int fOptionsMenu(){
    printf("This is options menu");
}
int fHelpMenu(){
    printf("This is help menu");
}



int main(void)
{
char myAnswer, c;
printf("[F]ile [E]dit [V]iew [O]ptions [H]elp \n"); scanf("%c", &myAnswer);
switch (myAnswer) {
case 'f':
case 'F': fFileMenu(); break;
case 'e':
case 'E': fEditMenu(); break;
case 'v':
case 'V': fViewMenu(); break;
case 'o':
case 'O': fOptionsMenu(); break;
case 'h':
case 'H': fHelpMenu(); break;
default: printf("I think your answer is Maybe ?\n");
}
c = getch();
return 0;
}

it writes menu's and when you pressed first letter it goes to function that you wanted. after this, program closes. But i dont want it. i want program that writes ' press z to go back to main function' and when you presed z it goes to main f. and it doesnt close. i wrote programe again. i made it for only file menu. but it doesnt worked for me. if you help me. thx for reading(sry for bad english.)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <stdio.h>
#include <conio.h>
int fFileMenu(){
    char zeta, c;
    printf("This is file menu\n");
printf("press z to go to main() function");scanf("%c", &zeta);    
switch (zeta) {
case 'z':
case 'Z': int main(void); break;
default: printf("I think your answer is Maybe ?\n");
c=getch();
     }

}
int fEditMenu(){
    printf("This is edit menu");
}
int fViewMenu(){
    printf("This is view menu");
}
int fOptionsMenu(){
    printf("This is options menu");
}
int fHelpMenu(){
    printf("This is help menu");
}



int main(void)
{
char zeta, myAnswer, c;
printf("[F]ile [E]dit [V]iew [O]ptions [H]elp \n"); scanf("%c", &myAnswer);
switch (myAnswer) {
case 'f':
case 'F': fFileMenu(); break;
case 'e':
case 'E': fEditMenu(); break;
case 'v':
case 'V': fViewMenu(); break;
case 'o':
case 'O': fOptionsMenu(); break;
case 'h':
case 'H': fHelpMenu(); break;
default: printf("I think your answer is Maybe ?\n");
}
c = getch();
return 0;
}

Last edited on
Topic archived. No new replies allowed.