我有一个文件,我必须读取一些数字并将它们放入数组中。唯一的问题是我不知道如何找到它的大小。我给了数组的最大大小,但数字不能完全填充数组。我尝试了许多不同的方法来使其工作,但它并没有从文件中读取正确的值。有没有其他的方式来做到这一点没有sizeof? #include<stdio.h>
#define MAX_NUMBER 25
int main(void)
{
int test[];
union u
{
int a;
float b;
char c[10];
};
int main()
{
union u abc;
printf("\n%d",sizeof(abc));
}
输出:12 我希望可以将输出为10.sizeof(焦炭)为1。因此,对于10我希望它是10.一个人能解释我为什么我们得到12.
我想下面的代码读取值创建的10个整数输入数组: int main() {
int x[10] ;
int a[] = {1,2,3,4,5} ;
int n ;
int b[n] ;
//int c[] ; gives compilation error
cout<<sizeof(x)<<endl ; //prints 40
我试图运行Python与PyPy(2.7)脚本,但我已经遇到了以下错误: TypeError: sys.getsizeof() is not implemented on PyPy.
A memory profiler using this function is most likely to give results
inconsistent with reality on PyPy. I