Skip to content
Browse files

add hostname

  • Loading branch information...
1 parent 07cb524 commit f1d9fc92c49ed27a1bbb83b75314090e880b7506 @liweinan committed Mar 31, 2013
Showing with 12 additions and 0 deletions.
  1. +3 −0 c/Makefile
  2. +9 −0 c/hostname.c
View
3 c/Makefile
@@ -38,6 +38,9 @@ play_stdarg: stdarg.o
null.o: null.c
cc null.c -o null.o
+hostname.o: hostname.c
+ cc hostname.c -o hostname.o
+
clean:
rm *.o
rm *.tmp
View
9 c/hostname.c
@@ -0,0 +1,9 @@
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int main() {
+ char* hn = malloc(sizeof(char) * 100);
+ gethostname(hn, sizeof(char) * 100);
+ printf("hostname: %s\n", hn);
+}

0 comments on commit f1d9fc9

Please sign in to comment.
Something went wrong with that request. Please try again.