Basic, I'm trying to read in a file that has lines of data, where each set is on a new line, and each variable is separated by whitespace, save for the name, which can have multiple white spaces. Here's basically my code, the parts that matter.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <iomanip>
std::ifstream inputFile; // Simple
inputFile.open("data.txt", std::ios::in);
while(i < MAXENTRIES && !inputFile.eof() && inputFile.good())
{
inputFile >> variable1;
inputFile >> variable2;
inputFile >> variable3;
inputFile >> variable4;
inputFile >> variable5;
// etc...
}
The loop works fine, it goes through twenty times, which is the maximum amount. However, nothing is read. I can do a quick printf on any variable immediately after it is "read," but they contain nothing. Any error checking I try comes up with nothing, so the loop still ones. What I really don't get is that the file read perfectly fine using C code (fscanf).
Any ideas?