Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/162.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当我以ifstream的形式打开linux系统文件时,为什么不能使用seekg(0,ifstream::end) 我想用C++获取机器的CPU信息,我的代码是: ifstream cpu_info_文件(“/proc/cpuinfo”,ifstream::_C++_Fstream_Ifstream_Seekg - Fatal编程技术网

当我以ifstream的形式打开linux系统文件时,为什么不能使用seekg(0,ifstream::end) 我想用C++获取机器的CPU信息,我的代码是: ifstream cpu_info_文件(“/proc/cpuinfo”,ifstream::

当我以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的形式打开linux系统文件时,为什么不能使用seekg(0,ifstream::end) 我想用C++获取机器的CPU信息,我的代码是:

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