Skip to content

Instantly share code, notes, and snippets.

@shelling
Created June 4, 2013 22:42
Show Gist options
  • Select an option

  • Save shelling/5710267 to your computer and use it in GitHub Desktop.

Select an option

Save shelling/5710267 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/sysctl.h>
char *
cpu_name() {
size_t buffer_size = 100;
char * buffer = malloc(sizeof(char) * buffer_size);
sysctlbyname("machdep.cpu.brand_string", buffer, &buffer_size, NULL, 0);
return buffer;
}
int main() {
printf("%s\n", cpu_name());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment