Monday, June 11, 2012

Read from a txt file and write into a char or string C++



#include<iostream>
#include<fstream>

using namespace std;

int main() {

 ifstream myReadFile;
 myReadFile.open("text.txt");
 char output[100];
 if (myReadFile.is_open()) {
 while (!myReadFile.eof()) {


    myReadFile >> output;
    cout<<output;


 }
}
myReadFile.close();
return 0;
} 
 
// this will tead text.text file and load content to output char and print it
 
//lochanaucsc 

No comments:

Post a Comment