newbie

Discussion about hacker.org's server
WINPINPH1
Posts: 28
Joined: Wed Oct 29, 2008 11:41 am

question again

Post by WINPINPH1 »

#include <fstream>
#include <iostream>

using namespace std;

int main()
{
char str[10];

//creates an instance of ofstream, and opens example.txt
ofstream a_file ("example.txt");
//output to example.txt through a_file
a_file<<"This text will now be inside of example.txt ";
//close the file stream explicitly
a_file.close();
//opens for reading the file
ifstream b_file ("example.txt");
//read one string from the file
b_file>>str ;
//should output 'this'
cout<<str <<"\n";
//b_file is closed implicitly here
cin.get();
}

the output in the console is 'this' what if i want the output is 'this text' or all of the string what should i modify to achieve my goal?

tia.
Post Reply