-2
저는 C++을 처음 사용합니다. 두 개의 .txt 파일이 있습니다. 하나는 다른 .txt 파일에서 찾길 원하는 3 가지 키워드입니다. 마녀는 긴 문자입니다. 두 파일을지도에 삽입하려고하는데 어떻게해야할지 모르겠다.지도에 파일을 삽입하십시오.
나는 이것을 시도했다 num.insert(pair<string,string>(clef,index));
그러나 그것은 효과가 없다. 도와주세요.
#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <iterator>
using namespace std;
ofstream index("index.txt", ios::out | ios::app);
int main()
{
map <string, string> num;
map <string,string> ::iterator it;
int ctrLigne = 1;
int ctrPage=1;
int ctr=1;
ifstream docum ("docum.txt", ios::in);
ifstream clef ("clef.txt", ios::in);
/* what I have tried but did not work
while (docum >> clef >> index){
num[clef] = index;
}
num.insert(pair<string,string>(clef,index));
num.insert(clef, index);
*/
if (docum)
{
string ligne;
while(getline(docum, ligne))
{
cout << ligne << " Ligne : " << ctrLigne << " Page : " << ctrPage << endl;
if(ctr==4)
{
ctr=0;
ctrPage++;
}
ctrLigne++;
ctr++;
}
docum.close();
clef.close();
system("pause");
return 0;
}
"작동하지 않음" –
이 문제에 필수적인 전체 코드를 게시하십시오. . – Ari0nhh