0
This syntax is not working in visual studio. Can someone explain why?
#include<iostream> #include <fstream> using namespace std; int main() { ofstream MyFile1("test.txt"); MyFile1 << "This is Awesome" << endl; MyFile1.close(); string line; ifstream MyFile("test.txt"); while (getline(MyFile, line)) { cout << line << endl; } MyFile.close(); } // getline is undefined identifier
3 Respostas
+ 1
The problem is resolved. Actually <string> header should be included for getline() to work.
+ 1
Can you please post the error message? Because it seems to work fine here.
+ 1
getline is undefined