-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstep1.cpp
More file actions
52 lines (46 loc) · 1.01 KB
/
step1.cpp
File metadata and controls
52 lines (46 loc) · 1.01 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
#include <iostream>
#include <fstream>
#include "dictionary.h"
using namespace std;
void PrintAllWordsWithDocpos(istream& in, int docpos) {
char word[MAXLEN+1];
int count = 0;
while(NextNonStopWord(in, word)) {
Capital2Lower(word);
cout << word << " "; cout.width(12);
cout << docpos << endl;
}
}
bool GetDocnamenDocpos(ifstream& fin, char *docname, int& docpos) {
SkipBlanks(fin);
if(fin.peek() == EOF) return false;
docpos = fin.tellg();
if(!(fin >> docname)) throw "말도안돼";
return true;
}
int main() {
ifstream fin("ir.docnames");
//ifstream fin("ir.mydocnames");
if(!fin) { cerr << "뭐야\n"; return 1; }
int docpos; // 문서명 저장 위치
char docname[MAXLEN+1]; //문서명
try
{
while (GetDocnamenDocpos(fin, docname, docpos))
{
ifstream in(docname);
if(!in)
{
cerr << docname << " in ir.docnames does not exist.\n";
continue;
}
PrintAllWordsWithDocpos(in, docpos);
in.close();
}
}
catch(char const *msg)
{
cout << msg << endl;
}
fin.close();
}