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.
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.
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.
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; }
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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With