标题:机构体数组,按书写的但是运行不了!!!
只看楼主
monajanny
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2014-4-26
结帖率:0
已结贴  问题点数:20 回复次数:1 
机构体数组,按书写的但是运行不了!!!
#include "stdio.h"
#define students 45
struct student
{
  char number[9];
  char name[8];
  char department[20];
};
struct address
{
  struct student student1;
  char telephone[12];
  char mobile[11];
  unsigned int QQ_number;
};
struct address student_addr[students];
int current_students;
void main()
{
    int t;
    int choice;
    for(t=0;t<=students;t++)
       student_addr[t].student1.number[0]=NULL;
    while(1)
  {choice=operation();
      switch(choice)
  { case'1':input();
      break;
      case'2':output();
      break;
      case'3':delete();
      break;
      case'4':return;}
  }
}
int operation()
{int c;
    printf("\n");
    printf("***************通信管理*****************\n");
    printf("*                                      *\n");
    printf("*       1.录入学生通信信息             *\n");
    printf("*       2.显示学生通信信息             *\n");
    printf("*       3.删除学生通信信息             *\n");
    printf("*       4.退出                         *\n");
    printf("*                                      *\n");
    printf("****************************************\n");
    printf("请选择<1-4>: ");
    while(1)
    {scanf("%d",&c);
     if(c<1||c>4)
      printf("提示:请按要求输入\n");
     else
     break;
    }
 return c;
}
void input()
{int pos;int i;
 if(current_students==students)
 { printf("存储空间已用完。\n");
     return;}
 for(i=0;i<=students;i++)
 {if(student_addr[i].student.number[0]==NULL)
     break;}
 pos=i;
 printf("number:");
 gets(student_addr[pos].student1t.number);
 printf("\nname:");
 gets(student_addr[pos].student1.name);
 printf("\ndepartment:");
 gets(student_addr[pos].student1.department);
 printf("\ntelephone:");
 gets(student_addr[pos].telephone);
 printf("\nmobile:");
 gets(student_addr[pos].mobile);
 printf("\nQQ_number:");
 scanf("%d",&student_addr[pos].QQ_number);
 current_students++;
 return;
}
void output()
int i;
{ for(int i=;i<=students;i++);
    {if(student_addr[i].student.number[0]!=NULL)
        printf("number:%s name:%s   department:%s  telephone:%s mobile:%s QQ_number:%s\n",
        student_addr[i].student1.number,student_addr[i].student1.name,student_addr[i].student1.department,
        student_addr[i].telephone,student_addr[i].mobile,
        student_addr[i].QQ_number);
    }
}
void delete()
{ char number[9];
    int pos,i;
    printf("请输入你想删除通信信息的学生的学号:");
    gets(number);
    for(i=0;i<=students;i++)
    {if(!strcmp(student_addr[i].student.number,number)
)break;}
    pos=i;
    if(pos>students)
{printf("找不到指定记录,删除没有完成。\n");
      return;}
 else
 {student_addr[pos].student.number[0]=NULL;
  printf("成功地将学号为:%s的记录删除!\n",number);
  current_student1--;}
  return;
  }
搜索更多相关主题的帖子: department operation telephone address include 
2014-04-26 15:05
yuccn
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:何方
等 级:版主
威 望:167
帖 子:6809
专家分:42393
注 册:2010-12-16
得分:20 
注意缩进,否则很难看的

我行我乐
我的博客:
http://blog.yuccn. net
2014-04-27 19:27



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-430677-1-1.html




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

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