| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 340 人关注过本帖
标题:请教关于c++编译输出的一个问题
只看楼主 加入收藏
寒天雪地
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2007-10-28
收藏
 问题点数:0 回复次数:6 
请教关于c++编译输出的一个问题
#include <iostream>
#include <stdafx>
#include <string>
usint namespace std;
int main(){
string strinfo="Please input your name:";
cout<<strinfo ;
cin>>strinfo;
return 0;
}

为什么结果编译出了问题:fatal error C1010: unexpected end of file while looking for precompiled header directive
执行 cl.exe 时出错.
希望高手指点,谢谢!
搜索更多相关主题的帖子: 输出 编译 
2007-10-28 20:20
songying
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2007-10-28
收藏
得分:0 
我也遇到过这种情况,不知道是怎么回事呢。

2007-10-28 20:24
xiaxin
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2007-10-21
收藏
得分:0 
#include <iostream>
//#include <stdafx>
#include <string>
using namespace std;
int main()
{
string strinfo="Please input your name:";
cout<<strinfo ;
cin>>strinfo;
return 0;
}
这样改是否符合题意?
我还没有用过这样来定义字符串,可以介绍一下吗?
2007-10-28 21:20
xiaxin
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2007-10-21
收藏
得分:0 
也许是<stdafx>拼写错误吧,程序根本不能跑起来.
而上面的却可以,请你别忘了,给我介绍介绍STRING头文件的用法,谢谢了.
2007-10-28 21:44
参股银行
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2007-10-28
收藏
得分:0 
只熟悉VB呢
2007-10-28 22:19
寒天雪地
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2007-10-28
收藏
得分:0 
回复:(songying)我也遇到过这种情况,不知道是怎么...

那就介绍一下std::string用法
string来代替char * 数组,
1、Define
string s1 = "hello";
string s2 = "world";
string s3 = s1 + "," + s2 +"!\n";
2、append
s1 += ",shanshan\n";
3、Compare
if(s1 == s2)
.....
else if(s1 == "hello")
.....
4、 string 重载了许多操作符,包括 +, +=, <, =, , [], <<, >>等,正式这些操作符,对字符串操作非常方便
#include <string>
#include <iostream>
using namespace std;
int main(){
string strinfo="Please input your name:";
cout << strinfo ;
cin >> strinfo;
if( strinfo == "winter" )
cout << "you are winter!"<<endl;
else if( strinfo != "wende" )
cout << "you are not wende!"<<endl;
else if( strinfo < "winter")
cout << "your name should be ahead of winter"<<endl;
else
cout << "your name should be after of winter"<<endl;
strinfo += " , Welcome to China!";
cout << strinfo<<endl;
cout <<"Your name is :"<<endl;
string strtmp = "How are you? " + strinfo;
for(int i = 0 ; i < strtmp.size(); i ++)
cout<<strtmp[i];
return 0;
}

不过这些都是以前的版本了!
现在不常用了,在读以前的源代码时会碰到!

2007-10-29 10:58
小小牙骋
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2007-10-29
收藏
得分:0 
我这根本就编译不了???
2007-10-29 12:46
快速回复:请教关于c++编译输出的一个问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012197 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved