Advertisement
wai0004

cpu model

Sep 17th, 2013
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.31 KB | None | 0 0
  1. int n;
  2. char line[1024], *p;
  3. FILE *f;
  4.  
  5. if (!(f = fopen("/proc/cpuinfo", "r")))
  6.     err(1, "fopen");
  7. n = 5;
  8. while (n--)
  9.     if(!fgets(line, sizeof(line), f))
  10.         err(1, "fgets");
  11. fclose(f);
  12. n = strlen(line);
  13. line[--n] = '\0';
  14.  
  15. if ((p = strchr(line, ':')) && (p + 2 - line) < n)
  16.     fputs(p + 2, stdout);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement