[英]A simple C code compile and run successfully in Borland Turbo C++ compiler but show errors in other compiler
I have run the following code in Borland Turbo C++ and can run successfully: 我已经在Borland Turbo C ++中运行了以下代码,并且可以成功运行:
#include<stdio.h>
int main()
{
int a;
int& b=a;
a=10;
printf("%d",a);
return 0;
}
But when I try to run it in code block or visual studio or dev C++ I get the following error message: 但是,当我尝试在代码块,Visual Studio或dev C ++中运行它时,出现以下错误消息:
[Error] expected identifier or '(' before '&' token [错误]预期标识符或'&'标记前的'('
I would like to use code block or visual studio but I can not fix up this error. 我想使用代码块或Visual Studio,但无法修复此错误。 What is the wrong am I doing.
我在做什么错。
(My apologies if this post sounds silly/stupid. I thought I'd ask here. Ignoring these core bits never made anyone a better programmer.) (如果这篇文章听起来愚蠢/愚蠢,我深表歉意。我想我想问一下。忽略这些核心知识永远不会使任何人成为更好的程序员。)
Thanks everyone. 感谢大家。
Probably you are trying to compile it using C compiler. 可能您正在尝试使用C编译器进行编译。 Try with C++ compiler like g++ it works!
尝试使用像g ++这样的C ++编译器就可以了!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.