I've been having troubles in getting 2 variables from a function. I've tried to put 2 variables in a function and somewhat code it like in vb put it doesn't save it, even if i declare 2 variable as globals outside of the main. and also my loop statement is kind of not ending if im put in a letter instead of a number. anyone who can help me with this? this is my code.. Thanks
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
char cname;
char cadd;
void displaymenu();
int getselection();
char getacct(char, char);
void showacct(char, char);
int main(){
char sel;
while(sel!=3){
clrscr();
displaymenu();
sel = getselection();
switch(sel){
case 1:
clrscr();
getacct(cname,cadd);
getch();
break;
case 2:
clrscr();
showacct(cname,cadd);
getch();
break;
}
}
clrscr();
cout << "Goodbye!!!";
getch();
return 0;
}
void displaymenu(){
cout << "\n\nAyn Interactive";
cout << "\nBanking Account Information";
cout << "\n 1. Create an account";
cout << "\n 2. View an account";
cout << "\n 3. Exit Program";
}
int getselection(){
int s;
cout << "\nSelection: ";
cin >> s;
return s;
}
char getacct(char cn,char ca){
cout << "Please enter name: ";
cin >> cn;
cout << "Please enter address: ";
cin >> ca;
return cn,ca;
}
void showacct(char cn,char ca){
cout << "Name is: " << cn;
cout << "Address is: " << ca;
}