hi everybody.
i am trying to develop a program that will be able to read and export informations (hw, sw, kernel, netstats..ecc) from a linux computer.
my idea was to use the files in the /proc directory but i can't get the script to work - this is what i got so far
#include <stdio.h>
#include <stdlib.h>
struct CpuInfo {
char vendor_id[50];
int family;
char model[50];
float freq;
char cache[20];
}
int main()
{
struct CpuInfo info = {"", 0, "", 0.0, ""};
FILE *cpuInfo;
if( ( cpuInfo = fopen("/proc/cpuinfo", "rb") == NULL ) ) {
printf("ERRORE! Impossibile aprire il file relativo alla CPU.");
}
else {
while (!feof(cpuInfo)) {
fread(&info, sizeof(struct CpuInfo), 1, cpuInfo);
if(info.family !=0) {
printf("%s\n%d\n%s\n%.2f\n%s\n", info.vendor_id, info.family, info.model, info.freq, info.cache);
}
}
}
return 0;
}
and this is the compiler output:
dude@gnixbox:~$ gcc -Wall -o cpuinfo cpuinfo.c
cpuinfo.c:13: error: two or more data types in declaration specifiers
cpuinfo.c:14: warning: return type of ‘main’ is not ‘int’
cpuinfo.c: In function ‘main’:
cpuinfo.c:20: warning: assignment makes pointer from integer without a cast
cpuinfo.c:32: warning: control reaches end of non-void function
anyone got ideas?suggestions?
thanks ;)