I want to write a C++ (C, if it provides easy solution to my problem) program where one may input until he chooses to signal end of input by pressing such combination of buttons as Ctrl+D. I have two questions regarding this.
- Which key-combination(s) is/are used to signal the end of input in Xterm? (Ctrl+C or Z didn't work)
What should be the logical code in my
while()
loop to process accordingly, when one presses the key combination as answered in 1?map<int,string>info; string name; int age; cin>>name; while( ????????? ){ //Input till EOF , missing logic cin>>age; info.insert( pair<int,string>(age,name) ); cin>>name; } //sorted o/p in reverse order map<int,string> :: iterator i; for(i=info.end(); i !=info.begin(); i--) cout<<(*i).second<<endl; cout<<(*i).second<<endl;
}
The program proceeds upon receiving the end of input signal from terminal.
I use gcc/g++ (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3
.
The while condition should be something like: