Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Print hostname
/* * Prints hostname and domain name. */ #include <unistd.h> #include <stdio.h> #define LENGTH 257 //hostname length. int main( void ) { int ret; //return code char hn[ LENGTH ]; ret = gethostname( hn, LENGTH ); if( ret ) //if `ret' is nonzero, { perror("gethostname"); return ret; } printf("Hostname: %s\n", hn ); char dn[ LENGTH ]; ret = getdomainname( dn, LENGTH ); if( ret ) { perror("getdomainname"); return ret; } printf("Domain Name: %s\n", dn ); }
run
|
edit
|
history
|
help
1
Project v0.07
Square pyramid
sphere
Tern operators
FUNTION4
C code to compare two texts in form of array of chars ignoring the capitalization
Midterm practice, turn into for loop
Project v0.12
Random test
My first reevers C 2darryp