sizeof(main())); 返回0; } / * main是一个函数指针! main()是函数int main(void)的调用。这将是返回以下大小的整数: sizeof(int)== sizeof(main()) * / 说明: double * X [5]; / * X是一个包含5个指针的数组加倍 * / 因此sizeof(X)= 5 * sizeof(double *) " double *"是指向双精度的指针(提示:从右向左移动) double(* Y)[5]; / * Y是指针到5个双打的数组* / 因此sizeof(Y)= sizeof(double(*)[5]) " double(*)[5]" ;是一个指向5个双打数组的指针(提示:从 里面移到外面) / * / * main是一个函数指针! main()是函数int main(void)的调用。这将是返回以下大小的整数: sizeof(int) 这个sizeof(main())大小相同,即返回的大小 整数 * / -anon.asdfTry this test program:/****************************/#include <stdio.h>double *X[5];/* X is an array of 5 "pointers to double" */double (*Y)[5];/* Y is a pointer to an array of 5 doubles */int main(void){ double array_of_5_double[] = {0.5, 1.5, 2.5, 3.5, 4.5}; X[0] = &array_of_5_double[0]; X[1] = &array_of_5_double[1]; X[2] = &array_of_5_double[2]; X[3] = &array_of_5_double[3]; X[4] = &array_of_5_double[4];#if 0 // why does this not work? X = {&array_of_5_double[0], /* array_of_5_double */ \ &array_of_5_double[1], \ &array_of_5_double[2], \ &array_of_5_double[3], \ &array_of_5_double[4]};#endif printf("sizeof(double) = %d // sizeof(double *) = %d //sizeof(double (*)[5]) = %d\n", \ sizeof(double), sizeof(double *), sizeof(double (*)[5])); /* 8 */ printf("sizeof(X) = %d // X = %p\n", sizeof(X), X,&array_of_5_double); printf("sizeof(X[0]) = %d // X[0] = %p // &array_of_5_double[0]= %p\n", sizeof(X[0]), X[0], &array_of_5_double[0]); // X[0] is the first element of our array: here it is a pointer to adouble with value 0.5 printf("sizeof(Y) = %d\n", sizeof(Y)); printf("sizeof(Y[0]) = %d\n", sizeof(Y[0])); // 40 printf("sizeof(main) = %d // sizeof(main()) = %d\n", sizeof(main),sizeof(main())); return 0;}/*main is a function pointer!main() is the invocation of the function "int main(void)" which willreturn an integer of the following size:sizeof(int) == sizeof(main())*/Explanations:double *X[5];/* X is an array of 5 "pointers to double" */Thus sizeof(X) = 5*sizeof(double *)"double *" is a pointer to a double (tip: move from right to left)double (*Y)[5];/* Y is a pointer to an array of 5 doubles */Thus sizeof(Y) = sizeof(double (*)[5])"double (*)[5]" is a pointer to an array of 5 doubles (tip: move frominside to outside)/*/*main is a function pointer!main() is the invocation of the function "int main(void)" which willreturn an integer of the following size:sizeof(int)This sizeof(main()) is the same size, i.e. the size of the returnedinteger*/-anon.asdf gr8说明: 只是想知道为什么 sizeof(主要)-1 sizeof(main( ))-sizeof(int)?????gr8 explanation:just wanted to know why doessizeof(main) -1sizeof(main()) -sizeof(int)????? Array类型为double的五个指针Array of five pointers to type double 大小为X报告 sizeof X 或 sizeof(double * [5]) 我推荐第一种方法。size of X is reported bysizeof Xorsizeof(double *[5])I recommend the first method. X [0]的大小报告由 sizeof X [0] 或 sizeof(双倍) 再次,我推荐第一种方法。size of X[0] is reported bysizeof X[0]orsizeof(double)Again, I recommend the first method. 指向五个双精度数组的指针/>Pointer to an array of five doubles 大小为X报告 sizeof X 或 sizeof(double(*)[5] 再次,我推荐第一种方法。size of X is reported bysizeof Xorsizeof(double(*)[5]Again, I recommend the first method. 大小X [0]报告 sizeof X [0] 或 sizeof(double [5]) 再次,我推荐第一种方法。size of X[0] is reported bysizeof X[0]orsizeof(double[5])Again, I recommend the first method. ''main''(没有括号)产生函数''main()''的地址为 。因此sizeof(main)将给出函数指针大小 。''main( )''调用 函数main(),并返回它的返回值。这个 类型''int''。 请注意,这些类型的大小会因平台而异(并且 $ b $对于相同的 平台,b可能会有所不同。 -Mike''main'' (without parentheses) yields the address ofthe function ''main()''. So sizeof(main) will givethe size of a pointer to a function. ''main()'' invokesthe function main(), and returns its return value. Thistype is ''int''. So ''sizeof(main())'' gives the size oftype ''int''.Note that these type sizes will vary among platforms (andcould conceivably vary among implementations for the sameplatform).-Mike 这篇关于一些指针问题....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-15 10:04