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",
|
||||
"type_traits": "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,
|
||||
tirq, tsoftirq = 0;
|
||||
FILE* ProcStatCPUThread = fopen("/proc/stat", "r");
|
||||
// char c = fgetc(ProcStatCPU);
|
||||
// while (c != -1) {
|
||||
// printf ("%c", c);
|
||||
// c = fgetc(ProcStatCPU);
|
||||
// }
|
||||
fscanf(ProcStatCPUThread, "cpu0 %llu %llu %llu %llu %llu %llu %llu",
|
||||
&tluser, &tnice, &tsystem, &tidle, &tiowait, &tirq, &tsoftirq);
|
||||
fscanf(ProcStatCPUThread, "%*s %llu %llu %llu %llu %llu %llu %llu",
|
||||
&tluser, &tnice, &tsystem, &tidle, &tiowait, &tirq, &tsoftirq); // WONT WORK
|
||||
fclose(ProcStatCPUThread);
|
||||
|
||||
std::cout << tluser << " " << tnice << " " << tsystem << " " << tidle
|
||||
|
||||
Reference in New Issue
Block a user