2014-09-19 2 views
-1

이상한 C3681 오류가 발생하여 내 기능 중 하나에서 식별자를 찾을 수 없다는 메시지가 계속 나타납니다. 나는 매우 혼란스럽고 Google을 사용하면서 발견 된 해결책을 시도했지만, 해결할 수는 없습니다. stl을 사용하지 않는 것이 좋습니다.C++에서 빌드 오류 얻기

오류 :

오류 1 오류 C3861 : 'readTheStuff': 식별자를 찾을 수 없습니다 C : \ 사용자 \ XXXXXX \ 바탕 화면 \ 데이터 구조 \ homework2 \ homework2 editor.cpp \ 38 일 Homework2

#include <iostream> 
#include <fstream> 
#include <string> 

using namespace std; 
int readFile(const char *fileName) { 
    ifstream myReadFile; 
    string line; 
    int i = 0; 
    myReadFile.open(fileName); 
    if (myReadFile.is_open()) { 
     while (!myReadFile.eof()) { 
      getline(myReadFile, line); 
      line += " "; //adds a space after every line 
      //cout << line << endl; 
      readTheStuff(line); 
     } 
    } 
    myReadFile.close(); 
    return 0; 
} 

void readTheStuff(string command){ 
    cout << command; //testing 
} 

int main(int argc, const char* argv[]){ //when they call, going to pass two parameters 
    if (argc > 2){ 
     cout << "Error, more than one file given" << endl; 
    } 
    else if (argc < 2){ 
     cout << "Error, no file given" << endl; 
    } 
    else if (argc == 2){ 
     readFile(argv[1]); 
    } 
} 

답변

4

함수를 호출하기 전에 선언해야합니다. readTheStuff 전에 신고하거나 readFile

0

두 가지 방법으로 위의 전체 기능을 위로 이동하십시오. 1.) 단지 editor.cpp

무효 readTheStuff (표준 : : 문자열 명령)

에 #include를 아래에 다음 줄을 포함하거나 다른 #include를 외에 다음 줄을 포함

#include "editor.h" 

내부에 다음 줄이

void readTheStuff(string command) 

이것은 프로토 타입이라고 표시해야 editor.h 및 선형에 컴파일러를 할 수 있습니다 nk readTheStuff(line) 실제 기능에 reaTheStuff(string command).