-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDSA.cpp
More file actions
85 lines (58 loc) · 1.58 KB
/
DSA.cpp
File metadata and controls
85 lines (58 loc) · 1.58 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <iostream>
#include <fstream>
#include <string>
#include <cstring> //because dirent stores dir names in char arrays...i.e. c type strings
#include <dirent.h> //format of directory entries
#include <sstream> //string stream
#include <vector> //to store the list of all the file names
using namespace std;
//hash function
unsigned long hashstring(unsigned char *str)
{
unsigned long hash = 5381;
int c;
while (c = *str++)
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
return hash;
}
//directory structure
DIR *dpdf;
struct dirent *epdf;
main()
{
cout<<"Enter the path of the directory in which you wish to search"<<endl;
string dir_path;
cin>>dir_path;
cout<<"The target directory is...\n"<<dir_path.c_str()<<endl;
//reading all the files in the directory
cout<<"Getting all files in this directory.....\n";
dpdf = opendir("./files/"); //opening the current directory
vector<string> files;
//printing the file names
if (dpdf != NULL)
{
while (epdf = readdir(dpdf)){
files.push_back(epdf->d_name);
}
}
//getting the number of files in the directory
long int num_files;
num_files=files.size();
//cout<<"number of files is "<<num_files<<endl;
/*int i;
for(i=0;i<num_files;i++)
cout<<files[i]<<endl;
*/
//getting the words from these files
char word[20];
streampos position
for(i=0; i<num_files; i++)
{
ifstream myfile ("files[i].txt");
if(myfile.is_open())
{
begin = myfile.tellg();
if()
}
}
}