I would like to check if my processor is AMD or INTEL in C and do necessary action according to that. What is the right and efficient way to get it in C?
Should i run system(linux command) or is there any other nice way to get it.
Since You didn't point an OS you are working at here is how you do it for OSX
#import <sys/sysctl.h>
I think that in c it is the same library just called by #include To use uint64_t type value you should include <stdint.h>
#include
uint64_t
<stdint.h>
#include <sys/sysctl.h> len=0; uint64_t freq = 0; // size_t size = sizeof(freq); sysctlbyname("machdep.cpu.brand_string", NULL, &len, NULL, 0); if(len) { sysctlbyname("machdep.cpu.brand_string", &freq, &len, NULL, 0); }
The answer you will get will be stored in freq
freq
To know the name of sysctlbyname you can run sysctl -a in terminal
sysctlbyname
sysctl -a
I think that sysctl is also compatible with linux but I never test it on linux machine
sysctl
http://www.unix.com/man-page/freebsd/3/sysctlbyname/
Since You didn't point an OS you are working at here is how you do it for OSX
I think that in c it is the same library just called by
#include
To useuint64_t
type value you should include<stdint.h>
The answer you will get will be stored in
freq
To know the name of
sysctlbyname
you can runsysctl -a
in terminalI think that
sysctl
is also compatible with linux but I never test it on linux machinehttp://www.unix.com/man-page/freebsd/3/sysctlbyname/