How would I go about...

How would I go about listing all the created txt files in the folder, and then accessing them one by one to edit or read them?

The following is what I have currently. It creates files, and you're able to write to them, but not access them for editing.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
  #include <iostream>
#include <string>
#include <fstream>

using namespace std;


int main()
{
	//ofstream
	ofstream fileController;
	string fileName;

	cout << "Enter the file you would like to write to: ";
	cin >> fileName;

	fileController.open(fileName, ios::app);

	string inputText;
	cout << "Input for as long as you want, type end to quit." << endl;
	while (inputText != "end")
	{
		getline(cin, inputText);
		if (inputText != "end")
		{
			fileController << inputText << endl;
		}
	}
	fileController.close();

	ifstream fileInput;

	cout << "\n\nEnter the file you would like to read to: ";
	cin >> fileName;

	fileInput.open(fileName);
	fileInput.seekg(ios::beg);
	string textOutput;
	while (!fileInput.eof())
	{
		getline(fileInput, textOutput);
		cout << textOutput << endl;
	}

	cin.get();
	cin.get();

	fileInput.close();
}
Reading directory content is OS-specific.
For example: http://www.gnu.org/software/libc/manual/html_node/Simple-Directory-Lister.html

There are portable frameworks that provide common interface and hide OS-details. For example, the Qt http://www.qt.io/
Is there any way I could do it just using fstream?
Is there any way I could do it just using fstream?

No way. With fstream you open or create files but you need to know the filename beforehand.
Topic archived. No new replies allowed.