2015-01-03 11 views
-1

getline()에 문제가 있습니다.
많은 예제를 시도하고 다른 솔루션을 읽었지만 문제가 해결되지 않았습니다. 나는 여전히 정보가 'getline: identifier not found'입니다. 나는 <stdio.h> <tchar.h> <iostream> <conio.h> <stdlib.h> <fstream>을 포함했지만 아직 아무것도 아닙니다.getline : 식별자를 찾을 수 없습니다.

#include "stdafx.h" 

using namespace std; 

int main(int argc, _TCHAR* argv[]) 

{ 

string line; 
getline(cin, line); 
cout << "You entered: " << line << endl; 

}  

지금해야 할 일은 무엇입니까? Win7 64 비트, MSVS2013을 사용합니다.

#include "stdafx.h" 
#include <iostream> 
#include <string> 

using namespace std; 

int main(int argc, _TCHAR* argv[]){ 
    string line; 
    getline(cin, line); 
    cout << "You entered: " << line << endl; 
} 
+4

''당신이 찾을 수있는 파일이 될 것입니다 [**'표준 : getline' **] (http://en.cppreference.com/w/cpp/string/basic_string/getline) – WhozCraig

+0

http://en.cppreference.com/w/cpp/string/basic_string/getline – juanchopanza

+1

짐작가는 것은 프로그래밍을하는 좋은 방법이 아닙니다. 설명서에서이 문제를 간단히 살펴 보지 못하게 한 이유는 무엇입니까? –

답변

0

당신은

#include "string" 

읽기 사용할 필요가 .
std::getline은 에서 찾을 수 있습니다.

#include <string> 
+0

''string ''이 아니고''이 아니며 [cppreference] (http://en.cppreference.com/w/cpp/string/basic_string/getline)를 활용하면서이 문제를 겪고 있습니다. – Mushy

5

이 그 문제를 해결해야합니다

0
#include "stdafx.h" 
#include <iostream> 
#include <string> 
using namespace std; 
    int main(int argc, _TCHAR* argv[]){ 
    string line; 
    /*To consume the whitespace or newline between the end of a token and the 
    beginning of the next line*/ 

    // eat whitespace 
     getline(cin >> ws, line); 
     cout << "You entered: " << line << endl; 
    } 
관련 문제