Difference between revisions of "Linux version"
From Teknologisk videncenter
(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...") |
m |
||
Line 22: | Line 22: | ||
} | } | ||
</source> | </source> | ||
− | [[Category:Linux]][[Category:C]] | + | [[Category:Linux]][[Category:C]][[Category:GNU]] |
Latest revision as of 07:52, 18 December 2022
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);
}