ok, im working on a program for class that takes int types in c and tells you the range and size
here is my code, but i get like 40 errors, and the compiler is pointing to the "{" at the begining of the RANGE function. can someone help me out here, im not see the error!
#include <stdio.h>
void RANGE(type, name)
{
type minval, maxval, bit;
unsigned bits;
char *format;
bits=1; bit=1;
while (bit<<=1)
{
bits++;
}
if ((type)(1L<<(bits-1))>0)
{
format="%12lu";
minval=(type)0;
}
else
{
format="%12ld";
minval=(type)(1L<<(bits-1));
}
maxval=minval-1;
printf("%20s (%2u bits): ", name, bits);
printf(format, (long) minval);
printf(" to ");
printf(format, (long) maxval);
printf("\n");
}
void main()
{
printf("\nTesting Range of Unsigned Ints... \n\n");
RANGE(unsigned char, "unsigned char");
RANGE(unsigned short int, "unsigned short int");
RANGE(unsigned int, "unsigned int");
RANGE(unsigned long int, "unsigned long int");
printf("\nTesting Range of Signed Ints... \n\n");
RANGE(signed char, "signed char");
RANGE(signed short int, "signed short int");
RANGE(signed int, "signed int");
RANGE(signed long int, "signed long int");
}