rendered paste body#include <stdio.h>
struct info{
char *arch;
char *os;
};
void getInfo( struct info *data){
data->arch = (char*) getenv("PROCESSOR_ARCHITECTURE");
if(data->arch ==NULL)data->arch = (char*)getenv("HOSTTYPE");
data->os = (char*) getenv("OS");
if(data->os ==NULL)data->os = (char*) getenv("OSTYPE");
}
void freeInfo(struct info *data){
// if(data->arch!=NULL)free(data->arch);
// if(data->os!=NULL)free(data->os);
}
void pc1(void){
printf ("-----------------------------------------\n");
printf("*** Intel Celeron x86-based PC ***\n\n");
printf("Size of:\n\tshort int = 16\n\tint = 32\n\tlong int = 32\n\tlong long int = 64\n\tint * = 32\n");
printf ("-----------------------------------------\n\n");
}
void sizeOf(void){
short int SHORT_INT;
int INT;
long int LONG_INT;
long long int LLONG_INT;
int *PINT;
printf("Size of:\n");
printf("\tshort int = %i\n",sizeof(SHORT_INT)*8);
printf("\tint = %i\n",sizeof(INT)*8);
printf("\tlong int = %i\n",sizeof(LONG_INT)*8);
printf("\tlong long int = %i\n",sizeof(LLONG_INT)*8);
printf("\tint * = %i\n",sizeof(PINT)*8);
}
int main(void){
struct info thisPC;
getInfo(&thisPC);
// size of ....
printf("All sizes are in bits\n\n");
printf("Other machines\n");
pc1();
printf ("-----------------------------------------\n");
printf("*** This machine ***\n\n");
(thisPC.arch !=NULL) ? printf("Arch: \t%s\n",thisPC.arch): printf("Arch: \tUnknown\n");
(thisPC.os !=NULL) ? printf("OS: \t%s\n",thisPC.os): printf("OS: \tUnknown\n");
sizeOf();
printf ("-----------------------------------------\n\n");
freeInfo(&thisPC);
return 0;
}