VS2010 需要先新建工程项目,接着在源文件中添加cpp文件,然后再编写代码,最后编译运行就可以,下面是创建执行C++程序的步骤:
1、首先新建项目(文件-->新建-->项目)
![](https://iknow-pic.cdn.bcebos.com/3801213fb80e7bec87eca843212eb9389b506b5a?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
2、提示需要选择项目的类型,找到Visual C++接着选择新建空项目,填入项目名称和选择项目保存的位置之后点击“确定”。
![](https://iknow-pic.cdn.bcebos.com/023b5bb5c9ea15ce9ad84babb8003af33a87b25a?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
3、Visual C++空项目新建完成后,还需要在源文件和头文件(右键“源文件”-->添加-->新建项)。
![](https://iknow-pic.cdn.bcebos.com/3b292df5e0fe9925513ac2f23aa85edf8db1715a?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
4、新建项也需要选择添加的文件类型,这里选择C++文件(cpp)即可。
![](https://iknow-pic.cdn.bcebos.com/f603918fa0ec08fad501b80557ee3d6d55fbda0b?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
5、在cpp文件中写完想要执行的代码后就可以调试运行了。(调试-->开始执行(不调试))。
![](https://iknow-pic.cdn.bcebos.com/0e2442a7d933c895ef5e33d9df1373f08202006b?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)