0
내 코드의 요점은 텍스트 내에 어딘가에 공백 -n이있는 파일을 입력 할 수 있다는 것입니다. 공백 -N을 (공백 -N) = 명사와 같은 사용자 프롬프트 코드로 변경하고 사용자에게 명사를 입력하도록 요청하지만 어떤 이유로 든 그 오류가 발생합니다. 그래서 여기에 내 코드가 있습니다 :C++ 오류 : 정의되지 않은 기호
//Author:
//
//
//
//
//
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using std::string;
using namespace std;
string getWord(ifstream &Infile, char &ch);
void getFilename(ifstream &Infile);
void getOutfile(ofstream &Outfile);
void putWord(ostream &Outfile,string word, char space);
string replacement(string word,std::string);
void printprompt(int i);
int main()
{
ifstream filename;
ofstream outfile;
string file;
string word;
char ch;
getFilename(filename);
getOutfile(outfile);
while(!filename.eof())
{
file =getWord(filename,ch);
putWord(outfile,file,ch);
}
filename.close();
outfile.close();
return 0;
}
string getWord(ifstream &Infile, char &ch)
{
string wrd = "";
Infile.get(ch);
while(ch !=' '&& ch != '\n' && !Infile.eof())
{
wrd.append(1,ch);
Infile.get(ch);
}
return wrd;
}
void getFilename(ifstream &Infile)
{
string filename;
cout<<"File for input: ";
cin >>filename;
Infile.open(filename.c_str());
if (Infile.fail())
{
cout << "Cannot open"<<filename<<endl;
exit(0);
}
}
void getOutfile(ofstream &Outfile)
{
string filename;
cout<<"file for output: ";
cin>>filename;
Outfile.open(filename.c_str());
if(Outfile.fail())
{
cout<< "Cannot open"<<Outfile<<endl;
exit(0);
}
}
void putWord(ofstream &Outfile,string word, char c)
{
Outfile << word;
if (c =='\n')
Outfile<<endl;
else
Outfile<<" ";
}
string replacement(string word)
{
string key[5]={"blank-N", "blank-A","blank-V","blank-P","blank-D"};
for(int i =0; i<5;i++)
{
if(word.compare(key[i]))
{
printprompt(i);
cin>>word;
}
return word;
}
}
void printprompt(int i)
{
switch(i)
{
case 0:
cout<<"Please enter a noun";
break;
case 1:
cout<<"Please enter an adjective";
break;
case 2:
cout<<"Please enter a verb";
break;
case 3:
cout<<"Please enter a place";
break;
default:;
}
}
나는 이러한 상황이 오류를 방지하는 방법을 모른다
Undefined first referenced
symbol in file
putWord(std::basic_ostream<char, std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, char)/var/tmp//ccdj0m4f.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
:
나는 것이 오류가 발생합니다.