Hi guys, quick question. I'm getting the "abnormal termination of program" when I'm trying to terminate my C program. I'm not sure why this is happening though (sorry, still a beginner when it comes to programming...)
you cannot obviously return a value in a void function as the compiler says , why dont you try to make it an integer return type function. what is your aim in this program exactly?
@c0defisher: That's actually just a part of the whole program. Basically, what happens is, when the user selects the 4th option, the application closes.
@Chervil: I'll try looking into that, thanks. If ever, this will be the first time that I'll be using that library.
Looking at the logic of the program, the while loop will terminate when opt == 4, so there may not be any need to do anything, other than output the message.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
while (opt!=4)
{
opt = menu();
switch(opt)
{
case 4:
clrscr();
printf("Exiting application...");
getch();
break;
case 5:
// etc.
}
}
When the break is executed at line 10, that ends the switch block. Then the while condition (opt!=4) is tested. Since it is no longer true, the loop terminates and the program will then exit normally.
Thus, there is no need to use any sort of exit function here.