CodeBlocks和VC2010之间的区别? [英] The difference between CodeBlocks and VC2010?...

查看:350
本文介绍了CodeBlocks和VC2010之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了一个有趣的东西:

使用Code :: Blocks进行编程时,以下程序(C)可以平稳运行:

I found an interesting stuff:

when programming using Code::Blocks, the following program(C) runs smoothly:

#include <stdio.h>
#include <stdlib.h>

int power(int m, int n);

main()
{
    printf("This is a program for exponientiation\n");
    int i;
    ...



但是,当我将这段代码复制到VC2010中时,其调试器检测到一些错误,因此我必须将其修改为以下形式,以使其在VC2010中顺利运行:



but, when i copied this piece of code into VC2010, its debugger detected several errors and i have to revise it into the following form to make it running smoothly in VC2010:

#include <stdio.h>
#include <stdlib.h>

int power(int m, int n);

main()
{

    int i;
     printf("This is a program for exponientiation\n");
     ...



而且这种形式(在变量定义之后放置了printf()的形式)在Code :: Blocks中也可以,谁能告诉我为什么会这样?
Code :: Blocks是否具有更好的容错能力,或者VC2010是否要求更严格的代码形式?


PS:一位朋友告诉我,第一种形式更可能是C ++,也许CodeBlocks对C和C ++之间的区别不太敏感?...



and this kind of form (where printf() has been placed after the definition of variables) works also okay in Code::Blocks, who could tell me why this happened?
Does the Code::Blocks enjoys a better fault tolerance or, does the VC2010 requires more strictly about the code form?


PS: a friend told me that the first form is more likely a C++ one, perhaps CodeBlocks is less sensitive to the difference between C and C++?...

推荐答案

第一种形式是C ++而不是C,因此,如果将它作为 C 程序(文件扩展名为.c)添加到VC2010中,则会出现错误.如果将与C++相同的代码保存(给文件一个.cpp扩展名),则应编译确定.这些只是语言的规则,我只能假定Code :: Blocks(无论是哪种语言)都无法正确执行这些规则.
The first form is C++ not C, so if you add it to VC2010 as a C program (with file extension .c) it will give errors. If you save the same code as C++ (give the file a .cpp extension) it should compile OK. These are just the rules of the languages, and I can only presume that Code::Blocks (whatever that is) does not enforce the rules correctly.


这篇关于CodeBlocks和VC2010之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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