当我以ifstream的形式打开linux系统文件时,为什么不能使用seekg(0,ifstream::end) 我想用C++获取机器的CPU信息,我的代码是: ifstream cpu_info_文件(“/proc/cpuinfo”,ifstream::
当我以ifstream的形式打开linux系统文件时,为什么不能使用seekg(0,ifstream::end) 我想用C++获取机器的CPU信息,我的代码是:当我以ifstream的形式打开linux系统文件时,为什么不能使用seekg(0,ifstream::end) 我想用C++获取机器的CPU信息,我的代码是: ifstream cpu_info_文件(“/proc/cpuinfo”,ifstream::,c++,fstream,ifstream,seekg,C++,Fstream,Ifstream,Seekg,当我以ifstream的形式打开linux系统文件时,为什么不能使用seekg(0,ifstream::end) 我想用C++获取机器的CPU信息,我的代码是: ifstream cpu_info_文件(“/proc/cpuinfo”,ifstream::in | ifstream::binary); streampos sp=cpu_info_file.tellg(); cout/proc中的大多数特殊文件没有固定的大小,它们的内容是在进程从它们读取()时动态生成的。从这些文件的末尾查找是不可
ifstream cpu_info_文件(“/proc/cpuinfo”,ifstream::in | ifstream::binary);
streampos sp=cpu_info_file.tellg();
cout/proc
中的大多数特殊文件没有固定的大小,它们的内容是在进程从它们读取()时动态生成的。从这些文件的末尾查找是不可能的。因此,如果我想在不读取整个文件的情况下在/proc中获取文件的最后几行,有什么方法吗?不读取整个文件-我不这样认为。好的,谢谢!
0
-1
-1
-1
ifstream cpu_info_file("cpuinfo",ifstream::in|ifstream::binary);
0
10424
10414
0