12345678910111213141516171819202122232425262728293031323334353637 |
- #include <stdio.h>
- #include <stdlib.h>
- const char *THERMFILE = "/sys/class/thermal/thermal_zone0/temp";
- int main(int argc, char **argv)
- {
- FILE *fp;
- float temperature = 0;
- fp = fopen(THERMFILE, "r");
- if (fp == NULL) {
- printf("Error: temperature file '%s' not found.\n", THERMFILE);
- printf("Look up where that file resides in your system, then change it in the source accordingly.\n");
- return 1;
- }
- fscanf(fp, "%f", &temperature);
- fclose(fp);
- printf("%.2f\n", temperature / 1000);
- return 0;
- }
|