intsize = sinzeof(int);报错E0029,求解


#include<stdio.h>

int main(void)
{
    int n = 0;
    size_t intsize;
    intsize = sinzeof(int);

    printf("n = %d, n has %zd bytes; all ints have %zdbytes.\n", n, sizeof n, intsize);

    return 0;
}

sinzeof打错了应该是sizeof,后面那个应该带上括号sizeof(n)

第8行是 sizeof 函数,你打错了,改正后如下:

#include<stdio.h>

int main(void)
{
    int n = 0;
    size_t intsize;
    intsize = sizeof(int);
    printf("n = %d, n has %zd bytes; all ints have %zd bytes.\n", n, sizeof n, intsize);
    return 0;
}

有关该函数的用法,可以参考: