Linux version

From Teknologisk videncenter
Revision as of 12:28, 13 December 2018 by Heth (talk | contribs) (Created page with "Checking the Linux version in C-code <source lang=c> #include <stdio.h> #include <sys/utsname.h> int main( void ) { struct utsname u; if ( uname( &u ) != 0 ) { perro...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Checking the Linux version in C-code

#include <stdio.h>
#include <sys/utsname.h>

int main( void ) {
  struct utsname u;

  if ( uname( &u ) != 0 ) {
    perror("Kald til uname(2) fejlede..");
  }
  printf("OS name.......: %s\n", u.sysname);
  printf("Nodename......: %s\n", u.nodename);
  printf("Release.......: %s\n", u.release);
  printf("Version.......: %s\n", u.version);
  printf("Machine.......: %s\n", u.machine);
#ifdef _GNU_SOURCE
  printf("Domainnam.e...: %s\n", u.domainname);
#endif

  return(0);
}