#include <iostream>
using namespace std;
main()
{
int desire;
cout << " MENU";
cout << " \n";
cout << " 1. Enter keyword (s)";
cout << " \n";
cout << " 2. View keyword (s) ";
cout << " \n";
cout << " 3. Exit";
cout << " \n";
cout << " Enter desired action : ";
cin >> desire;
cout << " \n";
cout << " \n";
return(0);
}
if(desire==1){
choice1();
main();
}else if(desire==2){
choice2();
main();
}else if(desire==3){
main();
exit(0);
}else{
printf("\n Invalid choice.");
main();
}
void choice1()
{
int i;
}
void choice2()
{
}
[code]
void choice3()
{
}
}
accept string as input then the program checks if the input is in the language recognizer program
Page 1 of 1
1 Replies - 468 Views - Last Post: 24 September 2009 - 08:20 PM
#1
accept string as input then the program checks if the input is in the
Posted 24 September 2009 - 08:11 PM
description: accept string as input then the program checks if the input is in the language in c++. There is a menu and either you choose the enter keyword, view and exit. As you input the words, the program will check the words into the program and print the correct words and the error words.
Replies To: accept string as input then the program checks if the input is in the
#2
Re: accept string as input then the program checks if the input is in the
Posted 24 September 2009 - 08:20 PM
I don't like to use if statements when you are going to parse the results afterwords anyhow. It's extra & wasted processing in my opinion.
#include <iostream>
using namespace std;
void choice(int opt) {
if(opt!=3) {
cout << "The option given was " << opt << endl;
}
else {
cout << "Now exiting...";
exit(0);
}
}
bool menu(void) {
int desire;
cout << " MENU";
cout << " \n";
cout << " 1. Enter keyword (s)" << endl;
cout << " 2. View keyword (s) " << endl;
cout << " 3. Exit" << endl;
cout << " Enter desired action : ";
cin >> desire;
cout << " \n";
cout << " \n";
choice(desire);
return true;
}
int main(void) {
while(menu());
return 0;
}
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|