Figured out the issue, scanf starts from begining of a stream

This commit is contained in:
Ben
2018-12-09 20:42:13 +00:00
parent 23d00f94ef
commit da20ea0626
3 changed files with 9 additions and 8 deletions

View File

@@ -33,6 +33,12 @@
"tuple": "cpp", "tuple": "cpp",
"type_traits": "cpp", "type_traits": "cpp",
"typeinfo": "cpp", "typeinfo": "cpp",
"utility": "cpp" "utility": "cpp",
"condition_variable": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"functional": "cpp",
"mutex": "cpp",
"sstream": "cpp"
} }
} }

Binary file not shown.

View File

@@ -57,13 +57,8 @@ void CPU::CPU_POLL(CPU* cpu) {
unsigned long long tluser, tnice, tsystem, tidle, tiowait, unsigned long long tluser, tnice, tsystem, tidle, tiowait,
tirq, tsoftirq = 0; tirq, tsoftirq = 0;
FILE* ProcStatCPUThread = fopen("/proc/stat", "r"); FILE* ProcStatCPUThread = fopen("/proc/stat", "r");
// char c = fgetc(ProcStatCPU); fscanf(ProcStatCPUThread, "%*s %llu %llu %llu %llu %llu %llu %llu",
// while (c != -1) { &tluser, &tnice, &tsystem, &tidle, &tiowait, &tirq, &tsoftirq); // WONT WORK
// printf ("%c", c);
// c = fgetc(ProcStatCPU);
// }
fscanf(ProcStatCPUThread, "cpu0 %llu %llu %llu %llu %llu %llu %llu",
&tluser, &tnice, &tsystem, &tidle, &tiowait, &tirq, &tsoftirq);
fclose(ProcStatCPUThread); fclose(ProcStatCPUThread);
std::cout << tluser << " " << tnice << " " << tsystem << " " << tidle std::cout << tluser << " " << tnice << " " << tsystem << " " << tidle