| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 520 人关注过本帖
标题:哪错啦?求帮助
只看楼主 加入收藏
陈雨
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2011-11-17
结帖率:0
收藏
已结贴  问题点数:20 回复次数:2 
哪错啦?求帮助
#include<stdio.h>
#include<string.h>
#define FORMAT "%s\n%s\n%d\n%s\n%f\n"
struct teacher
{
char name;
char sex;
int age;
char department;
float salary;
};
void main()
{
void print(struct teacher);
struct teacher tea1;
strcpy(tea1.name,"Mary");
strcpy(tea1.sex,"W");
tea1.age=40;
strcpy(tea1.department,"computer");
tea1.salary=1234;
print(tea1);
}
void print(struct teacher tea1)
{
    printf(FORMAT,tea1.name,tea1.sex,tea1.age,tea1.department,tea1.salary);
    printf("\n");
}
搜索更多相关主题的帖子: computer department teacher include 
2011-11-17 19:49
wuyijiang07
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:74
专家分:177
注 册:2011-10-21
收藏
得分:10 
程序代码:
#include<stdio.h>
#include<string.h>
#define FORMAT "%s\n%s\n%d\n%s\n%f\n"
struct teacher
{
char name[10];    //name,sex,department,都应该定义为字符型数组,这样才能存储字符串
char sex[2];
int age;
char department[20];
float salary;
};
void main()
{
void print(struct teacher);
struct teacher tea1;
strcpy(tea1.name,"Mary");
strcpy(tea1.sex,"W");
tea1.age=40;
strcpy(tea1.department,"computer");
tea1.salary=1234;
print(tea1);
}
void print(struct teacher tea1)
{
    printf(FORMAT,tea1.name,tea1.sex,tea1.age,tea1.department,tea1.salary);
    printf("\n");
} 
2011-11-17 20:04
shamozhiying
Rank: 2
等 级:论坛游民
帖 子:13
专家分:32
注 册:2011-2-21
收藏
得分:10 
楼上正解
2011-11-17 20:22
快速回复:哪错啦?求帮助
数据加载中...
 
   



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

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