int main(){
fstream in;
in.open ("myFile.dat", fstream::in | fstream::out | fstream::app);
char* temp = new char [40];
string aString;
in.write("123\n",4);
getline(in, aString); //in.read(temp, 4);
cout<<aString<<endl;
}
i want to either display the text already in myFile.dat or 123 if it was a empty file
i tested with a emtpy file, but the terminal display as a empty string, so how should i slove this problem?
wildplace 0 Junior Poster in Training
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
wildplace 0 Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.