Error with File Loading
Posted: Thu Dec 31, 2009 1:42 pm
Well, I was just screwing around with file loading, and this weird bug happened. I've fixed the bug, but I just wanted to post what happened.
Here's main.cpp:
And here's Dictionary.txt:
Here's main.cpp:
Code: Select all
#include <string>
#include <fstream>
#include <iostream>
int main()
{
std::string temp[5];
int i = 0;
std::fstream file;
file.open("Dictionary.txt");
if (file.is_open())
{
while (!file.eof())
{
std::getline(file, temp[i++]);
std::cout << temp[i++] << std::endl;
}
file.close();
}
else
{
std::cout << "Unable to load file";
}
return 0;
}
Code: Select all
Hello - A word
Testing - Testing
APPLES - ANOTHER WORD
banana - a fruit