| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 481 人关注过本帖
标题:找了三个小时,还是不知道在那出错
只看楼主 加入收藏
tpengti
Rank: 2
等 级:论坛游民
帖 子:75
专家分:18
注 册:2010-5-9
结帖率:65.22%
收藏
已结贴  问题点数:20 回复次数:2 
找了三个小时,还是不知道在那出错
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>


#define m 100
HANDLE hConsole;

void gotoxy(int x, int y)
{
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(hConsole, coord);
}


struct yonghu {                                                     /*个人注册信息*/
    char name[8];
    char sex[4];
    char class[20];
    char telephone[14];
    char qin_hao[3];
}student;
struct deng_lu {                                                    /*个人登录信息*/
    char zhang_hao[20];
    char mi_ma[6];
}yong_hu, stud;




void zhu_ce()                                                            /*注册界面*/
{
    FILE *ip, *fp;
    printf("请输入注册的个人信息:\n");
    printf("名字\t性别\t学部班级\t电话号码\t寝号\t用户名\t密码\n");
    scanf("%s%s%s%s%s%s%s", student.name, student.sex, student.class, student.telephone, student.qin_hao, yong_hu.zhang_hao, yong_hu.mi_ma);

    if((ip = fopen("student2.txt","a+")) == NULL) {
         printf("不能打开这个文件\n");
         return;
     }
    if(fwrite(&student,sizeof(struct yonghu),1,ip) != 1)
         printf("信息写入错误!");
    fprintf(ip,"\n");
    fclose(ip);   
    if((fp = fopen("denglu.txt","a+")) == NULL) {
         printf("不能打开这个文件\n");
         return;
     }
    if(fwrite(&yong_hu, sizeof(struct deng_lu), 1, fp) != 1)
         printf("信息写入错误!");
    fprintf(fp,"\n");
    fclose(fp);   
   
}


int jian_ce_1(char* xin_xi)                                          /*登录账号检测*/
{
   
    int  b;
    FILE *ip;

    ip = fopen("denglu.txt", "r+");
    for (b = 0; b < m; b++) {
        if(b)
        {
            fseek(ip, b * sizeof(struct deng_lu) + 2, 0);
            fread(&stud, sizeof(struct deng_lu), 1, ip);
        }
        else
            fread(&stud, sizeof(struct deng_lu), 1, ip);
        if(strcmp(stud.zhang_hao, xin_xi) == 0) {
            
            return (1);
        }
        continue;        
    }
   
    return (0);
}
int jian_ce_2(char* xin_xi)                                        /*登录密码检测*/
{
   

    int d;
    FILE *ip;

    ip = fopen("denglu.txt", "r+");
    for (d = 0; d < m; d++) {
        if(d)
        {
            fseek(ip, d * sizeof(struct deng_lu) + 2, 0);
            fread(&stud, sizeof(struct deng_lu), 1, ip);
        }
        else
            fread(&stud, sizeof(struct deng_lu), 1, ip);
        if(strcmp(stud.mi_ma, xin_xi) == 0) {
            
            return (1);
        }
        continue;        
    }
   
    return (0);
}
void deng_lu()                                                             /*登录界面*/
{
    int p, q, j;
    char new_zhang_hao[18];
    char new_mi_ma[6];
    printf("\t\t\t登录界面\t\t\t\n\n");
    printf("\t\t\t|---------------------------|\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t| 用户名:                  |\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t| 密 码 :                  |\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t|---------------------------|\n");
    hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    gotoxy(34, 4);
    scanf("%s", new_zhang_hao);
    p = jian_ce_1(new_zhang_hao);
    if (!p)
        printf("不存在这个账号:请先注册:\n");
    else {
        hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
         gotoxy(34, 6);
    for (j = 0; j < 6; j++) {
        new_mi_ma[j] = getch();
        printf("*");
    }
      q = jian_ce_2(new_mi_ma);
     if(!q) {
        hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
        gotoxy(34, 4);
          printf("密码错误:请重新输入:\n");
      }
    else {
        hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
        gotoxy(34, 4);
          printf("登录成功\n");
      }   
    }   
}
void zhu_jie_mian()
{
    int num1;
    printf("校园寝室管理系统\n\n\n");
    printf("\t\t\t 主界面\t\t\t\n\n");
    printf("\t\t\t|---------------------------|\n");
    printf("\t\t\t|         1-登录            |\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t|         2-注册            |\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t|         3-退出            |\n");
    printf("\t\t\t|---------------------------|\n");
    printf("请按编号选择要进入的界面:\n");
    scanf("%d", &num1);
    switch(num1) {
        case 1 : deng_lu(); break;                                                         /*登录*/
        case 2 : zhu_ce(); break;                                                          /*注册*/
        case 3 : printf("欢迎下次使用!\n");
                     break;                                                  /*退出*/
        default : printf("请重新选择!\n");
                      break;
}
void zhujiemian()
{
    int i;
    char num[6];
    char mima[6];
    printf("*******************************************************************************\n\n\n");
    printf("\t\t\t      校园寝室管理系统\t\t\t\n\n");
    printf("\t\t\t|---------------------------|\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t| 管理员:                  |\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t| 密 码 :                  |\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t|---------------------------|\n");
    hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
 
    gotoxy(34, 7);
   
    scanf("%s", num);
    hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    gotoxy(34, 9);
    for (i = 0; i < 6; i++) {
        mima[i] = getch();
        printf("*");
    }
    if (num[0] == 'l' && num[1] == 'i' && num[2] == 'n' && num[3] == 'u' && num[4] == 's' && mima[0] == '4' &&
        mima[1] == '5' && mima[2] == '2' && mima[3] == '3' && mima[4] == '2' && mima[5] == '3' ) {
        hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
        gotoxy(34, 15);
        printf("登录成功\n");
        zhu_jie_mian();
    }
    else {
        hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
        gotoxy(28, 15);
        printf("登录失败,请重新输入!\n");
    }

   
}
  
void main()                                                                    /*主函数*/
{
    zhujiemian();
}   

  

  
搜索更多相关主题的帖子: telephone include 信息 
2010-12-22 21:57
马后炮
Rank: 7Rank: 7Rank: 7
等 级:黑侠
帖 子:156
专家分:560
注 册:2010-12-17
收藏
得分:20 
我看看

樱之雪,晓之车
2010-12-22 22:06
d10G
Rank: 2
等 级:论坛游民
帖 子:7
专家分:15
注 册:2010-12-10
收藏
得分:0 
程序代码:
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h>//使用getch()函数需要该头文件


#define m 100
HANDLE hConsole;

void gotoxy(int x, int y)
{
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(hConsole, coord);
} 


struct yonghu {                                                     /*个人注册信息*/
    char name[8];
    char sex[4];
    char Class[20];//随便把你的class改成Class 因为class是C++的关键字,改了可减少可能出现的麻烦
    char telephone[14];
    char qin_hao[3];
}student;
struct deng_lu {                                                    /*个人登录信息*/
    char zhang_hao[20];
    char mi_ma[6];
}yong_hu, stud;




void zhu_ce()                                                            /*注册界面*/
{
    FILE *ip, *fp;
    printf("请输入注册的个人信息:\n");
    printf("名字\t性别\t学部班级\t电话号码\t寝号\t用户名\t密码\n");
    scanf("%s%s%s%s%s%s%s", student.name, student.sex, student.Class, student.telephone, student.qin_hao, yong_hu.zhang_hao, yong_hu.mi_ma);

    if((ip = fopen("student2.txt","a+")) == NULL) {
         printf("不能打开这个文件\n");
         return;
     }
    if(fwrite(&student,sizeof(struct yonghu),1,ip) != 1)
         printf("信息写入错误!");
    fprintf(ip,"\n");
    fclose(ip);   
    if((fp = fopen("denglu.txt","a+")) == NULL) {
         printf("不能打开这个文件\n");
         return;
     }
    if(fwrite(&yong_hu, sizeof(struct deng_lu), 1, fp) != 1)
         printf("信息写入错误!");
    fprintf(fp,"\n");
    fclose(fp);   
   
}


int jian_ce_1(char* xin_xi)                                          /*登录账号检测*/
{
   
    int  b;
    FILE *ip;

    ip = fopen("denglu.txt", "r+");
    for (b = 0; b < m; b++) {
        if(b)
        {
            fseek(ip, b * sizeof(struct deng_lu) + 2, 0);
            fread(&stud, sizeof(struct deng_lu), 1, ip);
        }
        else
            fread(&stud, sizeof(struct deng_lu), 1, ip);
        if(strcmp(stud.zhang_hao, xin_xi) == 0) {
           
            return (1);
        }
        continue;       
    }
   
    return (0);
}
int jian_ce_2(char* xin_xi)                                        /*登录密码检测*/
{
    

    int d;
    FILE *ip;

    ip = fopen("denglu.txt", "r+");
    for (d = 0; d < m; d++) {
        if(d)
        {
            fseek(ip, d * sizeof(struct deng_lu) + 2, 0);
            fread(&stud, sizeof(struct deng_lu), 1, ip);
        }
        else
            fread(&stud, sizeof(struct deng_lu), 1, ip);
        if(strcmp(stud.mi_ma, xin_xi) == 0) {
           
            return (1);
        }
        continue;       
    }
   
    return (0);
}
void deng_lu()                                                             /*登录界面*/
{
    int p, q, j;
    char new_zhang_hao[18];
    char new_mi_ma[6];
    printf("\t\t\t登录界面\t\t\t\n\n");
    printf("\t\t\t|---------------------------|\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t| 用户名:                  |\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t| 密 码 :                  |\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t|---------------------------|\n");
    hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    gotoxy(34, 4);
    scanf("%s", new_zhang_hao);
    p = jian_ce_1(new_zhang_hao);
    if (!p)
        printf("不存在这个账号:请先注册:\n");
    else {
        hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
         gotoxy(34, 6);
    for (j = 0; j < 6; j++) {
        new_mi_ma[j] = getch();
        printf("*");
    }
      q = jian_ce_2(new_mi_ma);
     if(!q) {
        hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
        gotoxy(34, 4);
          printf("密码错误:请重新输入:\n");
      }
    else {
        hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
        gotoxy(34, 4);
          printf("登录成功\n");
      }   
    }   
}
void zhu_jie_mian()
{
    int num1;
    printf("校园寝室管理系统\n\n\n");
    printf("\t\t\t 主界面\t\t\t\n\n");
    printf("\t\t\t|---------------------------|\n");
    printf("\t\t\t|         1-登录            |\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t|         2-注册            |\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t|         3-退出            |\n");
    printf("\t\t\t|---------------------------|\n");
    printf("请按编号选择要进入的界面:\n");
    scanf("%d", &num1);
    switch(num1) {
        case 1 : deng_lu(); break;                                                         /*登录*/
        case 2 : zhu_ce(); break;                                                          /*注册*/
        case 3 : printf("欢迎下次使用!\n");
                     break;                                                  /*退出*/
        default : printf("请重新选择!\n");
            break;
    }//**************************大括号少一个
}
void zhujiemian()
{
    int i;
    char num[6];
    char mima[6];
    printf("*******************************************************************************\n\n\n");
    printf("\t\t\t      校园寝室管理系统\t\t\t\n\n");
    printf("\t\t\t|---------------------------|\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t| 管理员:                  |\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t| 密 码 :                  |\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t|                           |\n");
    printf("\t\t\t|---------------------------|\n");
    hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

    gotoxy(34, 7);
   
    scanf("%s", num);
    hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    gotoxy(34, 9);
    for (i = 0; i < 6; i++) {
        mima[i] = getch();
        printf("*");
    }
    if (num[0] == 'l' && num[1] == 'i' && num[2] == 'n' && num[3] == 'u' && num[4] == 's' && mima[0] == '4' &&
        mima[1] == '5' && mima[2] == '2' && mima[3] == '3' && mima[4] == '2' && mima[5] == '3' ) {
        hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
        gotoxy(34, 15);
        printf("登录成功\n");
        zhu_jie_mian();
    }
    else {
        hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
        gotoxy(28, 15);
        printf("登录失败,请重新输入!\n");
    }

   
}

 
void main() //void main()不符合C语言标准。建议改成int main()                       /*主函数*/
{
    zhujiemian();
}
2010-12-22 22:14
快速回复:找了三个小时,还是不知道在那出错
数据加载中...
 
   



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

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