C++ ifstream
I'm putting my .txt file in Debug in the project folder. If you want to look at a sample of my code:
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
/*-----Function Prototypes-----*/
void importData(double []);
void displayTemps(double []);
int main () {
const int arraySize = 92;
double rawTemp[arraySize];
importData(rawTemp);
displayTemps(rawTemp);
}
void importData(double rawTemp[]){
int temp;
int count = 0;
ifstream inFile;
inFile.open("pgm7.txt");
while (inFile >> temp) {
rawTemp[count] = temp;
count++;
}
}
void displayTemps(double rawTemp[]){
for (int count = 0; count <= 31; count++) {
cout << setw(5) << right << count << setw(5) << rawTemp[count] << endl;
}
}
Any suggestions?
Mac OS X (10.6.3)