帮一帮我吧!

gangzichh 2005-12-10 04:19:58
#include<iostream>
#include<string>
using namespace std;


int main()
{
struct student
{
int num;
string name;
char sex;
float score;
};

student stu;
studnet * p=&stu;
stu.num=10301;
stu.name="wang fun";
stu.sex='f';
stu.score=89.5;
cout<<stu.num<<" "<<stu.name<<" "<<stu.sex<<" "<<stu.score<<endl;
cout<<(*p).num<<" "<<(*p).name<<" "<<(*p).sex<<" "<<(*p).score<<endl;
system("pause");
return 0;
}
为什么老是有错的???
...全文
272 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
gangzichh 2005-12-10
  • 打赏
  • 举报
回复
#include<iostream>
#include<string>
using namespace std;

struct student
{
int num;
string name;
char sex;
float score;
};

int main()
{
struct student stu={10301,"wangfan",'f',89.5};
struct student * p=&stu;

cout<<stu.num<<" "<<stu.name<<" "<<stu.sex<<" "<<stu.score<<endl;

cout<<(*p).num<<" "<<(*p).name<<" "<<(*p).sex<<" "<<(*p).score<<endl;
system("pause");
return 0;
}
这个是不对呀!
怎么回事的
wudanjack 2005-12-10
  • 打赏
  • 举报
回复
我是一名学c++的初学者,想请教楼主怎样学好c++这门语言,请指教!
gangzichh 2005-12-10
  • 打赏
  • 举报
回复
#include<iostream>
#include<string>
using namespace std;

struct student
{
int num;
string name;
char sex;
float score;
};

int main()
{
struct student stu={10301,"wangfan",'f',89.5};
struct student * p=&stu;

cout<<stu.num<<" "<<stu.name<<" "<<stu.sex<<" "<<stu.score<<endl;

cout<<(*p).num<<" "<<(*p).name<<" "<<(*p).sex<<" "<<(*p).score<<endl;
system("pause");
return 0;
}
这个是不对呀!
怎么回事的
wudanjack 2005-12-10
  • 打赏
  • 举报
回复
楼主好,第一次进入csdn,感到好高兴!
bm1408 2005-12-10
  • 打赏
  • 举报
回复
只是路过~
rain4609 2005-12-10
  • 打赏
  • 举报
回复
细心点好
happydivid 2005-12-10
  • 打赏
  • 举报
回复
没什么问题啊
就一个student单词拼写错误,改了后编译正确执行啊
zw24127 2005-12-10
  • 打赏
  • 举报
回复
不要笔下误呀!!!

(*p).num 可以写成 p->num 的
kevinlvchina 2005-12-10
  • 打赏
  • 举报
回复
就是,就是,单词拼错了,
sankt 2005-12-10
  • 打赏
  • 举报
回复
#include<iostream>
#include<string>
using namespace std;

struct student
{
int num;
string name;
char sex;
float score;
};

int main()
{
struct student stu={10301,"wangfan",'f',89.5f};
struct student * p=&stu; //以前这里有点笔误

cout<<stu.num<<" "<<stu.name<<" "<<stu.sex<<" "<<stu.score<<endl;

cout<<(*p).num<<" "<<(*p).name<<" "<<(*p).sex<<" "<<(*p).score<<endl;
system("pause");
return 0;
}
lzp229 2005-12-10
  • 打赏
  • 举报
回复
student stu;//struct student stu;
studnet * p=&stu;//struct student * p=&stu;

你单词都拼错了
Cantonese00 2005-12-10
  • 打赏
  • 举报
回复
#include<iostream>
#include<string>
using namespace std;

struct student
{
int num;
string name;
char sex;
float score;
};

int main()
{


student stu;
student * p=&stu;
stu.num=10301;
stu.name="wang fun";
stu.sex='f';
stu.score=89.5;
cout<<stu.num<<" "<<stu.name<<" "<<stu.sex<<" "<<stu.score<<endl;
cout<<(*p).num<<" "<<(*p).name<<" "<<(*p).sex<<" "<<(*p).score<<endl;
system("pause");
return 0;
}
改成这样不好么?

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧