以下两个代码段之间有什么区别? [英] What is the difference between the following two code snippets?

查看:112
本文介绍了以下两个代码段之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

int main( )
{
	long int zip; // Zip code
zip = 02137l; // Use the Zip code for Cambridge MA

std::cout << "New York's Zip code is: " << zip << '\n';
getch();
return(0);
}


&&


&&

int main( )
{
	long int zip; // Zip code
zip = 2137l; // Use the Zip code for Cambridge MA

std::cout << "New York's Zip code is: " << zip << '\n';
getch();
return(0);
}


为什么值ZIP会更改???


why the value ZIP is change ???

推荐答案

八角形.

在C ++中,从零开始的数字被当作八进制(以8为底)而不是十进制(以10为底)(除非零后面有一个"x",在这种情况下为十六进制(以16为底)). >
[edit]忘记了)"和两个大写字母...-OriginalGriff [/edit]
Octal.

In C++ numbers beginning with zero are taken as Octal (base 8), rather than Decimal, (base 10) (unless the zero has an "x" after it, in which case it is Hex (base 16)).

[edit]Forgot a ")" and two upper case letters... - OriginalGriff[/edit]


这篇关于以下两个代码段之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆