Apr 9, 2015 at 9:44am UTC
I just posted about the same tutorial. Mine compiles, but doesn't run properly. Are you using Visual Studio?
Apr 9, 2015 at 9:47am UTC
RTF files aren't really suitable for raw ifstream usage.
Use txt's.
Apr 9, 2015 at 10:17am UTC
S G H : thx for your response, I already tried this before posting, but it doesn't work either...
bostock11 : I'm on mac ! And I don't use IDE !
Apr 9, 2015 at 3:09pm UTC
1) What happens when you use a .txt file as S G H suggests?
2) Post both the line that shows you using a txt file, and also show us what is in the txt file.
Last edited on Apr 10, 2015 at 12:24am UTC
Apr 9, 2015 at 11:42pm UTC
What does infile.is_open() return?
Apr 10, 2015 at 12:21pm UTC
Is the txt file encoded in some weird format?
Apr 10, 2015 at 12:32pm UTC
Could you show your current code?
Edit: Make sure you get your text files name right
Edit 2: Im not sure how it works when you're not using an IDE but, make sure you're file is stored where its supposed to be, so the compiler can actualy find it.
Last edited on Apr 10, 2015 at 12:46pm UTC
Apr 10, 2015 at 12:57pm UTC
Man thats real weird... Works perfectly fine for me...
Apr 10, 2015 at 1:07pm UTC
... yes ... thank you to have checked it all
Apr 10, 2015 at 4:19pm UTC
Open the TXT file in a plain text editor like Notepad or Notepad++, not a rich text editor.
Apr 10, 2015 at 5:38pm UTC
I think it is down to the path of the input file.
Is the data file in the same directory with the executable?
Apr 10, 2015 at 5:46pm UTC
To find out what directory your program is looking for files in, run this code:
1 2 3 4 5 6
#include <fstream>
int main()
{
std::ofstream("use-this-directory.txt" ) << "Use this directory for input files." ;
}
Then just look for the file.
Some IDEs (especially Visual Studio) make this really confusing.
Last edited on Apr 10, 2015 at 5:47pm UTC