먼저 앞쪽은 메인 함수 중에 일부입니다. 이해하기 쉽도록,,혹시 모를 에러를 대비해서 올렸습니다. 참고 부분..
[code:1]
FILE *fp;
char tempbuf[1024]'
static long cpustate[4], oldstate[4], newstate[4], diffstate[4];
fp=fopen("/proc/stat","r");
fgets(tempbuf, 1023, fp);
fclose(fp);
sscanf( tempbuf, "%s %lu %lu %lu %lu", path, &newstate[0], &newstate[1], &newstate[2], &newstate[3] );
percentages( 4, cpustate, newstate, oldstate, diffstate );