Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getline: identifier not found

I have problem with getline().

I tried many examples and read other solutions, but that didn't solve my problem. I still have information 'getline: identifier not found'.

I included <stdio.h> <tchar.h> <iostream> <conio.h> <stdlib.h> <fstream> and still nothing.

#include "stdafx.h"

using namespace std;

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

What do I need to do now?

I use Windows 7 64 bit and Visual Studio 2013.

like image 943
Adam Fatyga Avatar asked Jan 03 '15 13:01

Adam Fatyga


People also ask

How do I find the Getline command in Visual Studio?

At the top of your file. See, for instance, c++ - getline: identifier not found - Stack Overflow [ ^ ]). That's where I looked to. Thank you :) You are welcome. I did a bit of a research and found a solution. Visual Studio needs the <string> library to identify the getline command.

Where do I find the identifier of a file?

At the top of your file. See, for instance, c++ - getline: identifier not found - Stack Overflow [ ^ ]). That's where I looked to. Thank you :) You are welcome. I did a bit of a research and found a solution.

Can STD::Getline be found in string?

cppreference is quite clear that std::getline may found in string. #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; }

How do I fix the use of an identifier error?

To fix this error, compare use of identifier to the identifier declaration for case and spelling. Verify that scope resolution operators and namespace using directives are used correctly. If the identifier is declared in a header file, verify that the header is included before the identifier is referenced.


1 Answers

Get used to simply reading the documentation for the language features that you use.
cppreference is quite clear that std::getline may found in string.

#include <string>
like image 86
Lightness Races in Orbit Avatar answered Sep 20 '22 15:09

Lightness Races in Orbit