Read from file.
#include <iostream> #include <fstream> using namespace std; int main() { ofstream out("test"); if(!out) { cout << "Cannot open file.\n"; return 1; } out << 10 << " " << 123.23 << endl; out << "This is a short text file."; out.close(); char ch; int i; float f; char str[80]; ifstream in("test"); if(!in) { cout << "Cannot open file.\n"; return 1; } in >> i; in >> f; in >> ch; in >> str; cout << i << " " << f << " " << ch << endl; cout << str; in.close(); return 0; }