Linux version

From Teknologisk videncenter
Revision as of 07:52, 18 December 2022 by Heth (talk | contribs)
(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);
}