Hyperlinked document system

I started working on C++. This is my second month and i am building building a hyperlinked document system similar to web pages on the Internet.


Import the contents of all .dox files in a given folder
Display the content of any given document
Calculate and display on request statistics about each document including:
The number of words
The average word length
The number of embedded links
Create an optimized search index for all the words in all the documents (ignore punctuation and case)
Provide a means to accept and execute user commands
Allow the user to search for and navigate to occurrences of specific words using the search index
Maintain a list of anchors (link endpoints) defined in each document
Resolve upon request any document links consisting of either:
A filename and an anchor, e.g. "|file.dox:my_anchor|" OR
A filename and a character index, e.g. "|file.dox:1032|" OR
A filename, e.g. "|file.dox:|"

I am able to open files, but they open all at ones.
Any input would be very helpful.
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
51
52
53
54
55
56
57
58
59
60
61
62
  #include "pch.h"
#include <iostream>
#include<string>
#include <vector>
#include <io.h>
#include <fstream>

using namespace std;

void FindFilesInPath(string& dirPath, vector<string*>& fileList)
{
	_finddata_t data;
	intptr_t ff = _findfirst(dirPath.c_str(), &data);
	if (ff != -1)
	{
		int res = 0;
		while (res != -1)
		{
			fileList.push_back(new string(data.name));
			res = _findnext(ff, &data);
		}

		_findclose(ff);
	}

	return;
}

/*void PrintMenu(string title) {
	cout << endl << title << "Menu" << endl;
	cout << "0-quit the program" << endl;
}*/

int main()
{
	string path;
	vector<string*> fileList;
	cout << "Enter a path: ";
	cin >> path;

	path.append("\\*.*");
	cout << path;
	FindFilesInPath(path, fileList);

	cout << endl << "File List:" << endl;
	for (string* item : fileList)
	{
		cout << *item << endl;
		string pathForFile = "hyperDocs\\" + *item;
		cout << pathForFile << endl;
		ifstream in(pathForFile);
		string strFromFile((istreambuf_iterator<char>(in)), istreambuf_iterator<char>());

		cout << strFromFile << endl;



	}


	return 0;
}
You've got much bigger fish to fry IMO.

Forget about "all the files" and just focus on satisfying all your requirements for just one file.

You need to make this work first.
1
2
3
4
5
6
7
8
void parseFile(const std::string &filename) {
    // The number of words
    // The average word length
    // The number of embedded links
}
int main ( ) {
    parseFile("hyperDocs\\file1.dox");
}




> I am able to open files, but they open all at ones.
If you meant "all at once", then that's because it's what you wrote.
You wrote a for loop to read each file and dump the contents.

> vector<string*> fileList;
No no no!
Just
vector<string> fileList;

Then
fileList.push_back(string(data.name));

You've only just started, and your code is full of memory leaks already.


Topic archived. No new replies allowed.