C++ 字符串 txt 读取

来源:百度知道 编辑:UC知道 时间:2024/05/23 18:12:09
#include<iostream.h>
#include<fstream.h>
void main()
{
char d[10];
struct sss
{
char data[10];
};
sss p;
ifstream infile("xx.txt",ios::in);
infile>>d;
p.data=d;
cout<<p.data<<endl;
}
如上是代码。编译时说p.data=d;这行" left operand must be l-value"
这是什么意思。该如何改?

字符数组是不能这样赋值的。。得用字符串函数来实现两个字符串的拷贝。。比如strcpm();此函数的具体解释如下:
http://baike.baidu.com/view/1026861.htm?fr=ala0