Figured out the issue, scanf starts from begining of a stream
This commit is contained in:
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
@@ -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.
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user