大众世界 world of demotic + 社区新动力

 找回密码
 注册会员
搜索
查看: 2794|回复: 0

[C++/C] 用vs2008创建运行c++项目

[复制链接]
发表于 2013-5-15 10:18:17 | 显示全部楼层 |阅读模式
1,选择文件--》新建--》项目    --》visual C++  模板中选择 空项目  ,输入名称和位置确定
2,在解决方案资源管理器中,右键点击 源文件 ---》添加--》新建项    在模板中选择 C++文件(.cpp)  ,输入名称T1.cpp添加
3, 打开这个cpp文件T1.cpp,添加文件头和命名空间
[C++] 纯文本查看 复制代码
#include<iostream>
using namespace std;
int a=5;
int square(int x);
int square(int x)
{
return x*x; 
}
void main()
{
int b;
cout<<"input b:";
cin>>b;
cout<<"b="<<b<<endl;
cout<<"a+b="<<a+b<<endl;
cout<<"b*b="<<square(b)<<endl;
system("pause");
}

4,运行就会看到结果。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Archiver|手机版|小黑屋|Wod Inc. ( 蜀ICP备20000008号-8

GMT+8, 2024-5-10 10:37 , Processed in 0.103260 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2023 Tencent Cloud.

快速回复 返回顶部 返回列表