Anonymous user
Menu: Difference between revisions
→{{header|C++}}: corrected; simplified
(→{{header|C++}}: corrected; simplified) |
|||
Line 98:
=={{header|C++}}==
<lang cpp>#include <iostream>
#include <boost/regex.hpp>
Line 104 ⟶ 103:
#include <string>
using namespace std;
void printMenu(const string *, int);
if (size == 0) { //we return an empty string when we call the function with an empty list
}
string entry;
bool ok = checkEntry(entry, terms, size);▼
printMenu(terms, size);
cout <<
cin >> entry;
}
int number = atoi(entry.c_str());
}
void printMenu(const string *terms, int num) {
for (int i = 1 ; i < num + 1 ; i++) {
Line 137 ⟶ 131:
}
}
bool checkEntry(string myEntry, const string *terms, int num) {
boost::regex e("^\\d+$");
Line 147 ⟶ 141:
return true;
}
int main( ) {
const string terms[ ] = { "fee fie" , "huff and puff" , "mirror mirror" , "tick tock" };
int size = sizeof terms / sizeof *terms;
cout << "You chose: " << dataEntry("Which is from the three pigs: ", terms, size);
return 0;
}</lang>
|