#include<string.h>
#include<stdio.h>
void main()
{
struct student
{
long num;
char name[20];
char sex;
float score;
}
struct student stu_1;
struct student *p;
p=&stu_1;
stu_1.num=89101;
strcpy (stu_1.name, "Li Li");
stu_1.sex='M';
stu_1.score=89.5;
printf (" NO.:%ld\n name:%s\n sex:%c\n score:%f\n",
stu_1.num, stu_1.name, stu_1.sex, stu_1.score);
printf (" NO.:%ld\n name:%s\n sex:%c\n score:%f\n",
(*p).num, (*p).name, (*p).sex, (*p).score);
}
大家帮我看看这个问题哦!
----------------解决方案--------------------------------------------------------
#include<string.h>
#include<stdio.h>
void main()
{
struct student
{
long num;
char name[20];
char sex;
float score;
}
struct student stu_1;
struct student *p;
p=&stu_1;
stu_1.num=89101;
strcpy (stu_1.name, "Li Li");
stu_1.sex='M';
stu_1.score=89.5;
printf (" NO.:%ld\n name:%s\n sex:%c\n score:%f\n",
stu_1.num, stu_1.name, stu_1.sex, stu_1.score);
printf (" NO.:%ld\n name:%s\n sex:%c\n score:%f\n",
(*p).num, (*p).name, (*p).sex, (*p).score);
}
大家帮我看看这个问题哦!
呵呵...
----------------解决方案--------------------------------------------------------
#include<string.h>
#include<stdio.h>
struct student
{
long num;
char name[20];
char sex;
float score;
};
void main()
{
struct student stu_1;
struct student *p;
p=&stu_1;
stu_1.num=89101;
strcpy (stu_1.name, "Li Li");
stu_1.sex='M';
stu_1.score=89.5;
printf (" NO.:%ld\n name:%s\n sex:%c\n score:%f\n",
stu_1.num, stu_1.name, stu_1.sex, stu_1.score);
printf (" NO.:%ld\n name:%s\n sex:%c\n score:%f\n",
(*p).num, (*p).name, (*p).sex, (*p).score);
}
大家帮我看看这个问题哦!
----------------解决方案--------------------------------------------------------
2楼的肯定不对!
虽然我不是强者!
----------------解决方案--------------------------------------------------------
2楼的肯定不对!
虽然我不是强者!
呵呵..二楼去掉红色代码是正确的
其实就是少了个分号.要不怎么写都正确.
结构体后面要加分号.
----------------解决方案--------------------------------------------------------
2楼的肯定不对!
虽然我不是强者!
呵呵``` 你门在机器上面可以看看 对不对哦...
肯定是正确的...只是把两中方法混用拉~~~
----------------解决方案--------------------------------------------------------
#include<string.h>
#include<stdio.h>
void main()
{
struct student
{
long num;
char name[20];
char sex;
float score;
}stu_1; //相当于结构体student定义一个变量是stu_1;所以这个程序是正确的.
struct student *p;
p=&stu_1;
stu_1.num=89101;
strcpy (stu_1.name, "Li Li");
stu_1.sex='M';
stu_1.score=89.5;
printf (" NO.:%ld\n name:%s\n sex:%c\n score:%f\n",
stu_1.num, stu_1.name, stu_1.sex, stu_1.score);
printf (" NO.:%ld\n name:%s\n sex:%c\n score:%f\n",
(*p).num, (*p).name, (*p).sex, (*p).score);
}
大家帮我看看这个问题哦!
----------------解决方案--------------------------------------------------------