I am having trouble seeing my finished product. Basically, I run the program and at the very last line of code, it executes, and then the screen disappears. Thus, I cannot see the final step.
Here is an example of some code I have been toying with:
#include <iostream>
usingnamespace std;
int main()
{
int size;
cout << "enter size of data array: ";
cin >> size;
double data[size]; //declare array of data
double datum;
int i;
for(i = 0; i < size; i++){
cout << "enter data: ";
cin >> datum;
data[i] = datum;}
//output the new data array
cout << "data array = {" << data[i] << "}";
return 0;
}
I want to fill an array of a user defined size with user defined data. In the last line of code I ask to see the array. When that line executes the display box the program is running in vanishes. As a result, I never get to see the last line!
1. change your IDE to one that keeps the output window open until you stop your code, or,
2. run the code from command line, or,
3. write a code that makes your program pause and insert it into your code e.g: http://www.cplusplus.com/forum/beginner/1988/
If you use Code::Blocks, it will keep the output window open at the end of your code.
Use: system("PAUSE") if your looking for a quick only windows method, or cin.get().
Use: define end as a string then at the end of the code do cin >> end;