![]() |
#1 | ||
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Mar 2006
Location: Krakeroy, Norway
Posts: 3,014
|
![]() I am (trying???) to learn C as part of my studies. Things are going fairly ok in programming but extending one task is giving me some grey hairs.
This code will output the size in bytes for various types of variables, as well as the value range. However, things are tricky when it comes to the float double both signed and unsigned, long and short, if it's there, I want to include it in the program. Code:
#include <stdio.h> #include <limits.h> #include <float.h> int main() { printf("char... \tsize: %d byte \t", sizeof(char)); printf("%d to %d \n", CHAR_MIN, CHAR_MAX); printf("unsgn char... \tsize: %d byte \t", sizeof(unsigned char)); printf("0 to %d \n", UCHAR_MAX); printf("short int... \tsize: %d bytes \t", sizeof(short int)); printf("%d to %d \n", SHRT_MIN, SHRT_MAX); printf("unsgn s int... \tsize: %d bytes \t", sizeof(unsigned short int)); printf("0 to %d \n", USHRT_MAX); printf("long int... \tsize: %d bytes \t", sizeof(long int)); printf("%ld to %ld \n", LONG_MIN, LONG_MAX); printf("unsgn l int... \tsize: %d bytes \t", sizeof(unsigned long int)); printf("0 to %u \n", ULONG_MAX); printf("float... \tsize: %d bytes \n", sizeof(float)); printf("double... \tsize: %d bytes \n)", sizeof(double)); return 0; } The float header was included as I messed around with different float constants not getting anywhere. Any input, so to speak, would be greatly appreciated!
__________________
Je Suis Charlie |
||
![]() ![]() |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
EoF Corner | Eagle of Fire | Offers | 6 | 03-02-2010 05:01 PM |
The end of the file corner | Eagle of Fire | Music, Art, Movies | 8 | 08-12-2009 12:09 AM |
Spoonman's Art Corner | Spoonman | Music, Art, Movies | 122 | 15-01-2009 09:35 PM |
Spoonman's Music Corner | Spoonman | Music, Art, Movies | 3 | 25-06-2005 05:18 PM |
|
|
||
  |