Skip to content

Instantly share code, notes, and snippets.

@mrahimygk
Forked from mortymacs/system_info.c
Last active January 31, 2017 11:08
Show Gist options
  • Save mrahimygk/fb16a53b071cb9447779caeaebe8d41a to your computer and use it in GitHub Desktop.
Save mrahimygk/fb16a53b071cb9447779caeaebe8d41a to your computer and use it in GitHub Desktop.
Showing system info
#include <stdio.h>
#include <stdlib.h>
#include <sys/utsname.h>
int main(int argc, char *argv[]) {
struct utsname *_system_ = malloc(sizeof(struct utsname));
uname(_system_);
if(argc==2 &&
(strcmp(argv[1], "version")==0
|| strcmp(argv[1],"VERSION" ) == 0))
printf("%s\n",_system_->version);
else{
printf("SYS NAME: %s\n", _system_->sysname);
printf("NODE NAME: %s\n", _system_->nodename);
printf("RELEASE: %s\n", _system_->release);
printf("VERSION: %s\n", _system_->version);
printf("MACHINE: %s\n", _system_->machine);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment