fieldfallow a écrit :
You are just kidding, aren't you ?
Compiling: main.c
main.c: In function `main_':
main.c:6: warning: 'c' might be used uninitialized in this function
main.c:7: warning: 'uc' might be used uninitialized in this function
main.c:8: warning: 's' might be used uninitialized in this function
main.c:9: warning: 'us' might be used uninitialized in this function
main.c:10: warning: 'i' might be used uninitialized in this function
main.c:11: warning: 'ui' might be used uninitialized in this function
main.c:12: warning: 'l' might be used uninitialized in this function
main.c:13: warning: 'ul' might be used uninitialized in this function
main.c:14: warning: 'f' might be used uninitialized in this function
main.c:15: warning: 'd' might be used uninitialized in this function
main.c:16: warning: 'ld' might be used uninitialized in this function
main.c:17: warning: 'v_p' might be used uninitialized in this function
I'm no sure long double is supported by my implementation. (Code::Blocks)
This code
#include <stdio.h>
#include <limits.h>
#include <float.h>
#define LONG_DOUBLE 0
int main(void)
{
char c=CHAR_MIN;
unsigned char uc=0;
short s=SHRT_MIN;
unsigned short us=0;
int i=INT_MIN;
unsigned int ui=0;
long l=LONG_MIN;
unsigned long ul=0;
float f=FLT_EPSILON;
double d=DBL_EPSILON;
long double ld=LDBL_EPSILON;
void *v_p=0;
printf(" c = '%c' or %d\n"
" uc = '%c' or %u\n"
" s = %hd\n"
" us = %hu\n"
" i = %d\n"
" ui = %u\n"
" l = %ld\n"
" ul = %lu\n"
" f = %f or %g\n"
" d = %f or %g\n"
#if LONG_DOUBLE
" ld = %Lf or %Lg\n"
#endif
"v_p = %p\n"
, (int) c
, (int) c
, (int) uc
, (unsigned) uc
, (short) s
, (unsigned short) us
, (int) i
, (unsigned) ui
, (long) l
, (unsigned long) ul
, (double) f
, (double) f
, (double) d
, (double) d
#if LONG_DOUBLE
, (long double) ld
, (long double) ld
#endif
, (void*) v_p);
puts("Initialising them with their maximum allowed values...");
c = CHAR_MAX;
uc = UCHAR_MAX;
s = SHRT_MAX;
us = USHRT_MAX;
i = INT_MAX;
ui = UINT_MAX;
l = LONG_MAX;
ul = ULONG_MAX;
f = FLT_MAX;
d = DBL_MAX;
ld = LDBL_MAX;
puts("Initialising v_p with NULL...");
v_p = NULL;
printf(" c = '%c' or %d\n"
" uc = '%c' or %u\n"
" s = %hd\n"
" us = %hu\n"
" i = %d\n"
" ui = %u\n"
" l = %ld\n"
" ul = %lu\n"
" f = %f or %g\n"
" d = %f or %g\n"
#if LONG_DOUBLE
" ld = %Lf or %Lg\n"
#endif
"v_p = %p\n"
, (int) c
, (int) c
, (int) uc
, (unsigned) uc
, (short) s
, (unsigned short) us
, (int) i
, (unsigned) ui
, (long) l
, (unsigned long) ul
, (double) f
, (double) f
, (double) d
, (double) d
#if LONG_DOUBLE
, (long double) ld
, (long double) ld
#endif
, (void*) v_p);
return 0;
}
Sounds correct to me:
c = 'Ç' or -128
uc = ' ' or 0
s = -32768
us = 0
i = -2147483648
ui = 0
l = -2147483648
ul = 0
f = 0.000000 or 1.19209e-007
d = 0.000000 or 2.22045e-016
v_p = 00000000
Initialising them with their maximum allowed values...
Initialising v_p with NULL...
c = '?' or 127
uc = ' ' or 255
s = 32767
us = 65535
i = 2147483647
ui = 4294967295
l = 2147483647
ul = 4294967295
f = 340282346638528860000000000000000000000.000000 or 3.40282e+038
d =
17976931348623157000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000.0000
00 or 1.79769e+308
v_p = 00000000