i want to read in the output of /proc/loadavg. Because this should be handled as a normal file, i thought i could do it this way (open the files, not yet read them):
But it seems like output.good() and output.close() dont return true, because no output is generated!
char* file = "/proc/loadavg";
// was able to open file
cout << "opened\n";
cout << "closed";
I already checked the rights.
When I create a text file in my home folder and open it with that code snipped, it works well.
Any ideas? Google and the board search did not provide any useful results.
I take it "cat /proc/loadavg" works?
Can you do "strace cat /proc/loadavg 2> trace.txt"
Then "strace myprog 2> trace2.txt"
Compare the open statements for /proc/loadavg and see if there is any difference.
> ofstream output;
You're opening an OUTPUT file for INPUT
What about this seems strange to you?
thank you both!
cout << buffer << "\n";