C++ Text File read formatted data
#include <fstream> #include <iostream> #include <string> using namespace std; int main()/*from www. j a v a 2 s . c om*/ { char ch; int j; double d; string str1; string str2; ifstream infile("fdata.txt"); //create ifstream object extract (read) data from it infile >> ch >> j >> d >> str1 >> str2; cout << ch << endl << j << endl << d << endl << str1 << endl << str2 << endl; return 0; }