Menu

[327ada]: / Templates / HelloInput_cpp.txt  Maximize  Restore  History

Download this file

28 lines (23 with data), 503 Bytes

 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
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
void Foo() {
cout << "Hello World!" << endl;
}
int main(int argc, char** argv) {
char input = 0;
cout << "Hello! This is a console application." << endl;
cout << "Press q to quit, press a to execute foo." << endl;
while(1) {
cin >> input;
if(input == 'a') {
Foo();
} else if(input == 'q') {
break;
} else if(input != '\n') {
cout << "Unknown command '" << input << "'! Ignoring...\n";
}
}
return 0;
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.