| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 460 人关注过本帖
标题:请教c的大大一个问题
只看楼主 加入收藏
飞飞我也
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2012-7-5
结帖率:90.91%
收藏
已结贴  问题点数:12 回复次数:4 
请教c的大大一个问题
#include <stdio.h>
#include <string.h>
int count = 0,i,flag;
struct student
{
    char name[8];        /*学号,姓名,年龄,性别,出生年月,地址,电话,E-mail*/
    char gender[2];
    int age;
    char number[20];
    char years[10];
    char address[80];
    char telephone[11];
    char email[50];
};
struct student stu[100];
new_student ()
{
    struct student temp;
    printf ("请您输入学生的姓名:");
    scanf ("%s", temp.name);
    printf ("请您输入学生的性别:");
    scanf ("%s", temp.gender);
    printf ("请您输入学生的年龄:");
    scanf ("%d", &temp.age);
    printf ("请您输入学生的学号:");
    scanf ("%s", temp.number);
    printf ("请您输入学生的出生年月:");
    scanf ("%s", temp.years);
    printf ("请您输入学生的地址:");
    scanf ("%s", temp.address);
    printf ("请您输入学生的联系电话:");
    scanf ("%s", temp.telephone);
    printf ("请您输入学生的邮箱:");
    scanf ("%s", temp.email);
    stu[count] = temp;
    count++;
}
search_name ()
{
    int choice2;
    char findname[8],findnumber[20];
    printf ("请您选择查询方式(姓名或学号):");
    scanf ("%d", &choice2);
    switch (choice2)
    {
    case 1:
        printf ("请您输入学生的姓名: ");
        scanf ("%s", findname);
        for (i = 0; i < 100; i++)
        {
                            if (strcmp(findname,stu[i].name)==0)
                            {
                                flag = 1;
                                break;
                            }
        }
                            if (flag)
                            {
                                printf("姓名:     %s\n",stu[i].name);
                                printf("性别:     %s\n",stu[i].gender);
                                printf("年龄:     %d\n",stu[i].age);
                                printf("出生年月: %s\n",stu[i].years);
                                printf("地址:     %s\n",stu[i].address);
                                printf("联系号码: %s\n",stu[i].telephone);
                                printf("E-mail:   %s\n",stu[i].email);
                            }
                            else
                            {
                                printf ("查不此人!!!\n");
                            }
                            break;
    case 2:
        printf ("请您输入学生的学号: ");
        scanf ("%s", findnumber);
        for (i = 0; i < 100; i++)
        {
                            if (strcmp(findnumber,stu[i].number)==0)
                            {
                                flag = 1;
                                break;
                            }
        }
                            if (flag)
                            {
                                printf("姓名:     %s\n",stu[i].name);
                                printf("性别:     %s\n",stu[i].gender);
                                printf("年龄:     %d\n",stu[i].age);
                                printf("出生年月: %s\n",stu[i].years);
                                printf("地址:     %s\n",stu[i].address);
                                printf("联系号码: %s\n",stu[i].telephone);
                                printf("E-mail:   %s\n",stu[i].email);
                            }
                            else
                            {
                                printf ("查不此人!!!\n");
                            }
                                    break;



main ()

{   
     int choice;
     printf("\n\t\t* * * * * 学生信息管理系统 * * * *\n");
     printf("\t\t*\t1.学生信息录入功能\t *\n");
     printf("\t\t*\t2.学生信息查询功能\t *\n");
     printf("\t\t*\t3.退出成绩管理系统\t *\n");
     printf("\t\t* * * * * 提供 * * * * * *\n\n");
     do
     {
         printf("\n请输入你要执行的操作:");
          scanf ("%d", &choice);
         switch (choice)
         {
        case 1:
            new_student ();
            break;
        case 2:
            search_name ();
            break;
        case 3:
            break;
        }
    }while (choice != 3);
}


错误:::
F:\\\1.c(101) : warning C4013: 'main' undefined; assuming extern returning int
F:\\\1.c(103) : error C2143: syntax error : missing ';' before '{'
F:\\\1.c(127) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

1.exe - 2 error(s), 1 warning(s)
搜索更多相关主题的帖子: 姓名 telephone address include 
2012-12-29 23:35
代号215
Rank: 2
等 级:论坛游民
帖 子:40
专家分:80
注 册:2012-11-22
收藏
得分:12 
程序代码:
#include <stdio.h>

 #include <string.h>

 int count = 0,i,flag;

 struct student

 {
     char name[8];        /*学号,姓名,年龄,性别,出生年月,地址,电话,E-mail*/
     char gender[2];
     int age;
     char number[20];
     char years[10];
     char address[80];
     char telephone[11];
     char email[50];

 };

 struct student stu[100];

 new_student ()

 {
     struct student temp;
     printf ("请您输入学生的姓名:");
     scanf ("%s", temp.name);
     printf ("请您输入学生的性别:");
     scanf ("%s", temp.gender);
     printf ("请您输入学生的年龄:");
     scanf ("%d", &temp.age);
     printf ("请您输入学生的学号:");
     scanf ("%s", temp.number);
     printf ("请您输入学生的出生年月:");
     scanf ("%s", temp.years);
     printf ("请您输入学生的地址:");
     scanf ("%s", temp.address);
     printf ("请您输入学生的联系电话:");
     scanf ("%s", temp.telephone);
     printf ("请您输入学生的邮箱:");
     scanf ("%s", temp.email);
     stu[count] = temp;
     count++;

 }

 search_name ()

 {
     int choice2;
     char findname[8],findnumber[20];
     printf ("请您选择查询方式(姓名或学号):");
     scanf ("%d", &choice2);
     switch (choice2)
     {
     case 1:
         printf ("请您输入学生的姓名: ");
         scanf ("%s", findname);
         for (i = 0; i < 100; i++)
         {
                             if (strcmp(findname,stu[i].name)==0)
                             {
                                 flag = 1;
                                 break;
                             }
         }
                             if (flag)
                             {
                                 printf("姓名:     %s\n",stu[i].name);
                                 printf("性别:     %s\n",stu[i].gender);
                                 printf("年龄:     %d\n",stu[i].age);
                                 printf("出生年月: %s\n",stu[i].years);
                                 printf("地址:     %s\n",stu[i].address);
                                 printf("联系号码: %s\n",stu[i].telephone);
                                 printf("E-mail:   %s\n",stu[i].email);
                             }
                             else
                             {
                                 printf ("查不此人!!!\n");
                             }
                             break;
     case 2:
         printf ("请您输入学生的学号: ");
         scanf ("%s", findnumber);
         for (i = 0; i < 100; i++)
         {
                             if (strcmp(findnumber,stu[i].number)==0)
                             {
                                 flag = 1;
                                 break;
                             }
         }
                             if (flag)
                             {
                                 printf("姓名:     %s\n",stu[i].name);
                                 printf("性别:     %s\n",stu[i].gender);
                                 printf("年龄:     %d\n",stu[i].age);
                                 printf("出生年月: %s\n",stu[i].years);
                                 printf("地址:     %s\n",stu[i].address);
                                 printf("联系号码: %s\n",stu[i].telephone);
                                 printf("E-mail:   %s\n",stu[i].email);
                             }
                             else
                             {
                                 printf ("查不此人!!!\n");
                                 break;
                             }
                               
     }

 }


void main()
{  
      int choice;
      printf("\n\t\t* * * * * 学生信息管理系统 * * * *\n");
      printf("\t\t*\t1.学生信息录入功能\t *\n");
      printf("\t\t*\t2.学生信息查询功能\t *\n");
      printf("\t\t*\t3.退出成绩管理系统\t *\n");
      printf("\t\t* * * * * 提供 * * * * * *\n\n");
      do
      {
          printf("\n请输入你要执行的操作:");
          scanf ("%d", &choice);
          switch (choice)
          {
         case 1:
             new_student ();
             break;
         case 2:
             search_name ();
             break;
         case 3:
             break;
         }
     }while (choice != 3);

 } 

  问题不大  都是楼主犯的小错误 希望楼主自己下次认真找

好久没把牛皮吹的这么清新脱俗了
2012-12-29 23:40
飞飞我也
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2012-7-5
收藏
得分:0 
,原来大括号问题。。。。。
2012-12-29 23:43
代号215
Rank: 2
等 级:论坛游民
帖 子:40
专家分:80
注 册:2012-11-22
收藏
得分:0 
楼主的程序 运行之后会崩溃    实践证明

好久没把牛皮吹的这么清新脱俗了
2012-12-29 23:44
飞飞我也
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2012-7-5
收藏
得分:0 
回复 4楼 代号215
额。。。怎么崩溃了?可以说说怎么改了
2012-12-30 00:49
快速回复:请教c的大大一个问题
数据加载中...
 
   



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

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