Martine 发表于 2018-6-9 20:32:57

long& int 的输出问题

#include <stdio.h>

int main(void)
{
        long sum =0;//int OK
        long i;
        while(i<10)
        {
                if(i&1) //even
                {
                        goto update;
                        i++;
                }
                sum +=i;
update:
                i++;
        }
        printf("sum = %ld\n", sum);
}

七月水水 发表于 2018-6-9 21:29:34

我的VS2017,两个运行结果一样一样的{:10_327:}

xypmyp 发表于 2018-6-9 23:34:11

When writing in C or C++, every datatype is architecture and compiler specific. On one system int is 32, but you can find ones where it is 16 or 64; it's not defined, so it's up to compiler.

https://stackoverflow.com/questions/7456902/long-vs-int-c-c-whats-the-point

Martine 发表于 2018-6-10 14:53:15

xypmyp 发表于 2018-6-9 23:34
When writing in C or C++, every datatype is architecture and compiler specific. On one system int is ...

Your answer perfectly solved my puzzle! THX ^_^

68629219 发表于 2018-6-10 15:11:06

oh perfect your english si so good
页: [1]
查看完整版本: long& int 的输出问题