注册 登录
编程论坛 C++教室

对数据成员字符串赋值的问题

huxiangking 发布于 2008-11-10 22:39, 1019 次点击
c++中据说比c有很多关于字符串操作的
用 char *a;
cout<<a;能否
再者 scanf("%d",&a);行不
我一程序声明的用来初始化对象
void card::ini()
{
    cout<<"请依次输入该扑克牌的ID(1-52),花色,面值,背景图案的编号:"<<endl;
    scanf("%d,%s,%d,%d",&(this->id),&(this->suit),&(this-rank),&(this->imagnum));
};
提示这个东西error C2102: '&' requires l-value
在线求解 多谢~
5 回复
#2
huxiangking2008-11-10 22:53
没人给个提示啊~~伤↑
#3
huxiangking2008-11-10 22:57
睡觉了 单元明早能想起来
#4
sunkaidong2008-11-11 10:34
#include "iostream"
using namespace std;
typedef struct a
{
    char *p;
}a;
int main()
{
    a a1;
    strcpy(a1.p=(char*)malloc(100),"adadasd");
    cout<<a1.p<<endl;
    return 0;
}
#5
huxiangking2008-11-11 22:21
回复 4# 的帖子
是对类的数据成员赋值,要在exe上输入数据,
还是感谢~
改了另一种方法 用string类型变量就能直接用cout了
#6
pascale2008-11-12 23:51
getline
1