I was trying to open file and read it using C++. Here's the code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void open_file(string filename)
{
string data;
ifstream file;
file.open(filename);
file >> data;
cout << data;
}
int main()
{
open_file("file.txt");
}
But the output ends when character in file is space. File:
This message will be printed
Output:
This
Could somebody help me?