no member named line in std

Hi , I'm trying to write on file but here is a problem : where there is get line(input.line)) , Xcode return me an error : no member named 'line' in std::_1::basic_ifstream<char,std::_1::char_traits<char>>'. Can you help me ? Thanks

#include <iostream>

#include <fstream>

#include <string>


usingnamespacestd;

using std::ofstream;

using std::ifstream;

using std::string;


int main()

{

string line ;

cout<<" Cosa vorresti scrivere sul file ? "<<endl;

ofstream output;

output.open("myfile.txt");

while( line != "exit"){

output<<line<<endl;

cin>>line;

}

output.close();

cout<<"Ho scritto sul file !"<<endl<<endl;

cout<<"Contenuto file:"<<endl;

ifstream input;

input.open("myfile.txt");

while (getline(input.line)){

cout<<line<<endl;

}

input.close();

return 0;

}

MacBook Pro with Retina display, macOS Mojave (10.14), Nvidia 750M + 16 GB of Ram

Posted on Nov 5, 2018 12:43 PM

Reply
Question marked as Top-ranking reply

Posted on Nov 6, 2018 9:42 AM

The variable line is a string, and you need to replace that period (e.g membership) with a comma.


while (getline(input, line)) {

cout<<line<<endl;

}

1 reply

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

no member named line in std

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.