00000000000000000000000000000000000000000000000000 0000000000000000000000 $ b $ 00 00000000000000000000000000000000000000000000000000 0000000000000000000000 $ b $ 00 00000000000000000000000000000000000000000000000000 0000000000000000000000 00000000000000000000000000000.000000 或1.79769e + 308 v_p == 00000000 我认为空指针的值为零。为什么gcc'的可执行文件 打印ffffffffh? ld的值似乎也是错误的。 演示的代码是: #include< stdio.h> #include< limits.h> #include< float.h> int main(void){ char c; unsigned char uc; short s; unsigned short us; int i; unsigned int ui; long l; unsigned long ul; float f; 双d; long double ld; void * v_p; printf (" c ==%c\\\\tor%d\\\uc ==%c\\\\\\ t%u \ ns ==%hd \ nus ==%hu \ n" " i ==%d \ nui ==%u \ nl ==%ld \ nul ==%lu \ nf ==%f \ n \\\ %% g \ n" " d ==%lf \ n \\\%%\\ t%\ nd} ==%Lf \ n \%%Lg \ nv_p ==%p \\ \\ n", c,c,uc,uc,s,us,i,ui,l,ul,f,f,d,d,ld,ld,v_p); put(初始化它们与他们的最大允许值...); 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\\\\\\ id%d \ nuc ==%c \ n \\\ t%u \ ns ==%hd \ nus ==%hu \ n" " i ==%d \ nui ==%u \ nl ==%ld\\\ul ==%lu \ nf ==%f \ n \\ n%\\ n \\ n%\ n \\ n> " d = =%lf \ n \%%\\ t \\ t%\ nd} ==%Lf \ n \\\%%Lg \ nv_p ==%p \ n", c,c,uc ,uc,s,us,i,ui,l,ul,f,f,d,d,ld,ld,v_p); 返回0; } 错误在哪里? 感谢所有帮助。 解决方案 fieldfallow< fi*********@gmail.com>在新闻中写道:dtmt1n 1g3 1 @ emma.aioe.org: 我认为空指针的值为零。为什么gcc的可执行文件打印ffffffffh? http://c-faq.com/null/index.html 思南 - A. Sinan Unur< 1u ** @ llenroc.ude.invalid> (反转每个组件并删除.invalid for email address) Hello all, Before stating my question, I should mention that I''m fairly new to C. Now, I attempted a small demo that prints out the values of C''s numerictypes, both uninitialised and after assigning them their maximum definedvalues. However, the output of printf() for the long double ''ld'' and thepointer of type void ''v_p'', after initialisation don''t seem to be right. The compiler used was gcc (mingw) with ''-Wall'', ''-std=c99'' and''-pedantic'' switches. No warnings were emitted. Incidentally the MSVisual C++ 2003 compiler''s output seems okay. I give them both below: gcc''s output:ld == -1.#QNAN0or -1.#QNANv_p == FFFFFFFF msvc''s output:ld == 17976931348623157000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000.000000or 1.79769e+308v_p == 00000000 I thought null pointers had a value of zero. Why is gcc''s executableprinting ffffffffh? Also the value of ''ld'' seems to be wrong. The code for the demo is:#include <stdio.h>#include <limits.h>#include <float.h> int main(void) {char c;unsigned char uc;short s;unsigned short us;int i;unsigned int ui;long l;unsigned long ul;float f;double d;long double ld;void *v_p; printf("c == %c\n\tor %d\nuc == %c\n\tor %u\ns == %hd\nus == %hu\n""i == %d\nui == %u\nl == %ld\nul == %lu\nf == %f\n\tor %g\n""d == %lf\n\tor %g\nld == %Lf\n\tor %Lg\nv_p == %p\n",c,c,uc,uc,s,us,i,ui,l,ul,f,f,d,d,ld,ld,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\n\tor %d\nuc == %c\n\tor %u\ns == %hd\nus == %hu\n""i == %d\nui == %u\nl == %ld\nul == %lu\nf == %f\n\tor %g\n""d == %lf\n\tor %g\nld == %Lf\n\tor %Lg\nv_p == %p\n",c,c,uc,uc,s,us,i,ui,l,ul,f,f,d,d,ld,ld,v_p);return 0;} Where is the mistake?Thanks for all the help. 解决方案 fieldfallow <fi*********@gmail.com> wrote in news:dtmt1n1g31@emma.aioe.org: I thought null pointers had a value of zero. Why is gcc''s executable printing ffffffffh? http://c-faq.com/null/index.html Sinan--A. Sinan Unur <1u**@llenroc.ude.invalid>(reverse each component and remove .invalid for email address) 这篇关于printf()错误,带有long double和null指针。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-22 00:37