| | |
A C Program to display as much information about system as possible
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
This Program gives the details (name, kernel, machine type, domain, groups, sizeof data types, etc) of the host it is running on.
/* hostDetails.c - display as much information about system as possible */ #include <unistd.h> #include <sys/types.h> #include <stdio.h> #include <sys/utsname.h> #include <pwd.h> #include <stdlib.h> #define MAX_DOMAIN_LEN 512 #define MAX_HOST_LEN 512 int main(int argc, char *argv[]) { int counter; /* to be used by uname() */ struct utsname uname_buf; /* to be used by getdomainname() */ char domain[MAX_DOMAIN_LEN]; /* to be used by getgroups() */ gid_t *list=NULL; int num_gid; /* to be used by gethostname() */ char host_buf[MAX_HOST_LEN]; /* check all things are provided */ if (argc != 1 ) { printf("call with no parameter\n usage: maxInfo\n\n"); exit(-1); } uname(&uname_buf); printf("Result of uname()\n"); printf("sysname = %s\n", uname_buf.sysname); printf("nodename = %s\n", uname_buf.nodename); printf("release = %s\n", uname_buf.release); printf("version = %s\n", uname_buf.version); printf("machine = %s\n", uname_buf.machine); printf("\n"); printf("Result of getdomainname()\n"); getdomainname(domain, MAX_DOMAIN_LEN); printf("domain name = %s\n", domain); printf("\n"); printf("Result of getegid()/getgid()\n"); printf("gid = %lu\n", (unsigned long) getgid()); printf("effective gid = %lu\n", (unsigned long) getegid()); printf("\n"); printf("Result of getgroups()\n"); num_gid = getgroups(0, list); list = (gid_t *) malloc (sizeof(gid_t)*num_gid); num_gid = getgroups(num_gid, list); if (list != NULL) { for (counter=0; counter<num_gid; counter++) { printf("%lu ", (unsigned long) list[counter]); } } printf("\n"); printf("\n"); printf("Result of gethostid()/gethostname()\n"); printf("host id = 0x%lx\n", gethostid()); gethostname(host_buf, MAX_HOST_LEN); printf("host name = %s\n", host_buf); printf("\n"); printf("Result of sizeof() (in bytes)\n"); printf("sizeof(char) = %d\n", sizeof(char)); printf("sizeof(short) = %d\n", sizeof(short)); printf("sizeof(int) = %d\n", sizeof(int)); printf("sizeof(long) = %d\n", sizeof(long)); printf("sizeof(long long) = %d\n", sizeof(long long)); printf("sizeof(float) = %d\n", sizeof(float)); printf("sizeof(double) = %d\n", sizeof(double)); printf("sizeof(long double) = %d\n", sizeof(long double)); return 0; }
0
•
•
•
•
I'm compiling with the old TC 2.0v and some syntax errors come up, may be because the 'ancient' compiler I'm using.
Bofarull
Bofarull
Similar Threads
- can two ms sql table display information on one vb datagrid??? (Visual Basic 4 / 5 / 6)
- display information from access table in a combobox (Visual Basic 4 / 5 / 6)
- Getting information from database and display on the screen (PHP)
- ActiveX or Java program to collect system/hardware information (Existing Scripts)
- Program to display System date and Time in VC++ 6.0 (C++)
| Thread Tools | Search this Thread |
Tag cloud for C
adobe ansi api array arrays asterisks binarysearch calculate centimeter char command convert copyimagefile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax directory dynamic executable fflush file fork forloop frequency getlasterror givemetehcodez graphics gtkgcurlcompiling hacking hardware highest homework i/o inches incrementoperators infiniteloop kernel km lazy linked linkedlist linux linuxsegmentationfault list lists locate logical_drives match matrix microsoft motherboard multi mysql number open opendocumentformat opensource owf pattern pdf performance pointer pointers posix problem probleminc program programming radix recursion recv repetition research scanf scheduling scripting segmentationfault send sequential shape socketprograming spoonfeeding stack standard string strings structures student systemcall testautomation turboc unix user variable visualstudio voidmain() wab win32 windows.h



