Answer the question
In order to leave comments, you need to log in
How to read data from a file into a line (there is 1 line in the file)?
There is a text file (it is known that it has 1 line) and you need to read it in string (any String ^, even string), but the number of spaces and characters is unknown. How to do it? getline() didn't help
Answer the question
In order to leave comments, you need to log in
Is this code not working?
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(int argc, char *argv[]) {
ifstream file("text.txt");
string str;
getline(file, str);
cout << str << endl;
system("pause");
return 0;
}
Do you write under .net? Then https://msdn.microsoft.com/en-us/library/db5x7c0d(...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question