I'm writting (have pretty much finished it now) a console program that takes two sentences works out the difference between them and applies those changes to each line of a file. What i would like to know is:
1) When i run my program through my IDE (codewarrior) once the program has finished the dos console stays open untill a key is pressed, if however the program is run straight from its .exe icon the console instantly closes as soon as the program has finished. Since i want the user to be able to read error messages i was wondering if anyone could tell me a line of code that will make the program wait for a key to be pressed before closing the console even when run from it's .exe icon.
2) I have the user enter a string of numbers followed by a character those numbers are stored in a vector<int>, the code i'm using is:
where i is an int and spaces is a vector<int>. This works fine but seems clumsy, is there a simple way for me to have the user enter numbers (all on one line separated by spaces) into a vector<int> without asking him to finish off with a character?Code:while (cin >> i) spaces.push_back(i);
3) I ask the user a series of yes and no questions where they reply with either 'Y' or another character, currently i'm just using
where c is a character, thing is if they type in "YY" to the first question by mistake the second question catches the second Y. Is there a way to avoid this other than using fgets()? IE. Is there some way i can flush the input stream after the first question is answered so i lose the second character?Code:cin >> c
Thanks in advance for any help provided