#include <iostream>
#include <string>
#include <fstream>
std::string getVersion(){
std::ifstream f {"lsb"};
std::string text;
if (f) {
for (std::string line; std::getline(f, line); )
text += line + "
";
f.close();
}
std::cout << text;
return text;
}
int main() {
std::ofstream o{"lsb"};
if (o) {
o << "// reading binary file
#include <iostream.h>
#include <fstream.h>";
o.close();
}
getVersion();
}
https://wandbox.org/permlink/hxYMoAsGPvsZaja8не получаю ошибок, проверьте прогу в valgrind, что-то течет, и да, почему нет return у функции?
public: string getVersion(){
ifstream f ("/etc/lsb-release");
string line;
string text;
if (f.is_open()){
while (getline (f,line))
{
text += line + "\n";
}
cout << text;
f.close();
}
}