Hello everyone.....
I've learned a lot in the last few days, thanks to all of you and the tutorials on this site. Thanks most sincerely.
So.... what I've learned so far is how to write a half-functioning/half-not-functioning data entry program using arrays. I'm getting it... I'm almost there.... My question is this:
I'm getting a weird number appearing on the line after the data entry. It's the same number every time : 1244532
Obviously I've done something wrong. Is anyone willing to give me a hint? Loop weirdness? Some sort of missing statement after the data entry? Gremlins?
Also... sort of the same subject... I seem to be bracket impaired... are there any handy tips for figuring out where they need to be placed and proper indentation thereof?
Code:#include <conio.h> #include <fstream.h> #include <iomanip.h> #include <iostream.h> #include <math.h> ofstream fout; int main () { // variable declarations double array [65]; int i, j, index, data; // alphabetized variable dictionary // i is vertical spacing // j is horizontal spacing //============================================================== fout.open ("prompt.txt"); // this is a program to store data in a single array cout << setw (50) << " " << endl; cout << endl << endl << endl << endl << endl << endl << endl; cout << setw (50) << "Storing Data in an Array" << endl; cout << endl << endl << endl << endl << endl << endl << endl << endl; // press any key to continue cout << setw (50) << "Press return to continue" << endl; getchar(); clrscr (); //============================================================== // run program until user is done do { // set initial values to 0 data = 0; index = 0; // prompt the user for the next data cout << endl << endl << endl << endl<< endl << endl << endl << endl; cout << setw (60) << "Enter -1 for end of data; Enter next data # " << data +1 << ": "; cin >> array [index]; // display data entered cout << setw (38) << " : " << array << endl; index = index +1; data = data +1; cout << endl << endl << endl << endl << endl << endl; getchar(); } while (array [index -1]!= -1); // ask the user to verify accuracy of data and to correct any errors //{ cout << setw (60) << "Enter index of incorrect data; Enter 0 for none: " << data << ": "; //} fout.close (); return 0; }