Do I have to put the file somewhere?

Do I have to have the file saved (I have it saved in My Documents) in a particular folder? It's not giving any results.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  #include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main()
{
	ifstream inputFile;
	string name;

	inputFile.open("abc.*txt");

	while (inputFile >> name)
	{
		cout << name << endl;
	}

	inputFile.close();

	return 0;
}


Thanks all.
You need to have the file in the current working directory, generally the same directory as the executable binary that is produced.
Uh.. I'm just a Freshman, I created a random Notepad file. And... It'd be great if you can make your explanation simpler. Thanks.

Unless you meant that I have to put the Notepad file into my Project folder, shall try that...
Last edited on
Topic archived. No new replies allowed.