1
Name:
Anonymous
2009-12-03 16:15
// project created on 12/3/2009 at 8:23 PM
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
int main(int argc, char *argv[]) {
FILE *f;
char s[255];
char *bogo = NULL;
char tmp[9];
unsigned int val = 0;
unsigned int i = 0;
unsigned int c = 0;
f = fopen("/proc/cpuinfo", "rt");
if (f == NULL) {
printf("We are probably on iShit or WinShit\n");
} else {
while (!feof(f)) {
fgets(s, LINE_MAX, f);
bogo = strstr(s, "bogomips");
if (bogo != NULL) {
i = c = val = 0;
while (bogo[i] != ':') i++;
i += 2;
while (bogo[i] != '.') {
tmp[c] = ' ';
tmp[c] = bogo[i];
bogo[i] = ' ';
c++;
i++;
}
val = atoi(tmp);
printf("%i\n", val);
}
}
fclose(f);
}
printf("Done\n");
return 0;
}
7
Name:
Anonymous
2009-12-03 17:04
Dumb.
if(a){
die-with-an-error();
} else{
/* wasted one indentation level */
lines-of-code();
}
Compare to:
if(a){
die-with-an-error();
}
lines-of-code();
I always prefer the latter.
And, yeah, I want to know what game is it that compiles on win/mac yet uses linux functionality (i.e. no syscalls at all, written in pure C) and needs to know performance of the computer.