In my linux machine if i try to copy /proc/stat it is creating 0 byte file. but if i do cat /proc/stat it has data. but the size always shows as 0.
cp /proc/stat statfile
is creating zero byte file. If i write a program to copy then it worked. why is it so ?
int main()
{
std::ifstream procFile("/proc/stat");
std::ofstream outfile("statfile");
char buf[1024];
while (!procFile.eof() && procFile.is_open())
{
procFile.getline(buf, 1024);
outfile << buf<<endl;
}
procFile.close();
outfile.close();
return 0;
}