How to call a function to go to another/new screen?

For each function when chosen in the menu i need them to go to another screen, i tried system("cls") but i got errors.

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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include <stdio.h>
#include <stdlib.h>


char menu();
float Getdeposit( float);
float Getwithdraw( float);
void displaybalance(float);


int main()
 {

 char menu1;
float newbalance = 0;

do {
menu1 = menu();


switch(menu1)
{
case 'd':
case 'D':
newbalance = Getdeposit(newbalance);

break;

case 'w':
case 'W':
newbalance = Getwithdraw(newbalance);
break;

case 'b':
case 'B':
displaybalance(newbalance);
break;

case 'q':
case 'Q':
printf("Thank you!");
break;
default:
printf(" You have not entered a valid choice! ");
break;
}
}while (menu1 != 'Q');

return 0;
}


char menu()
{

char menu;
printf(" Welcome to HFCC Federal Credit Union! ");
printf("\n Please select from the following menu: ");
printf("\n D: Make a deposit \n W: Make a withdrawl \n B: Check your account balance \n Q: To quit \n");
scanf("%c", &menu);
return(menu);
}

float Getdeposit(float balance )
{


 float deposit;
 while (1)
 {
 printf("What is the ammount you would like to deposit?");
 scanf("%f", &deposit);
 if (deposit <= -1)
 {
 printf("\n Sorry you enterd a negative number, please try again");
continue;
}
 return ( balance =  balance + deposit );
}
}


float Getwithdraw(float balance)
{
float withdraw;
while (1)
{
printf("How much would you like withdraw?");
scanf("%f", &withdraw);
if (withdraw <= -1 )
{
printf("\nSorry you enterd a negative number, please try again");
continue;
}
(balance = balance - withdraw);
if (balance <= -1)
{
printf("\nSorry insufficeint funds");
continue;
}
return (balance);
}
}


void displaybalance(float newbalance)
{
printf("Current balance: %.2f", newbalance);

}

Hi
I've not tried my self, but you may try this

http://justcheckingonall.wordpress.com/2008/08/29/console-window-win32-app/
You need to include the header <windows.h> to use system("cls"); .
Last edited on
1) windows.h is not a lib, it is a header file.
2) You do not need to include windows.h to use system("cls"), as systems calls an external program.
3) system is evil. Using it introduces a serious security risk in your application by virtue that you are calling an external application that could have been replaced with a virus.

If you want to clear your screen after each selection you're going to have to learn a little bit of the API for your OS of choice.



(or if you don't really care about security or have no reason to worry about it go ahead and use system for your OS's clear screen program and post the errors you are having)
Last edited on
Topic archived. No new replies allowed.