⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bintro.c

📁 本源程序是一电子投票平台
💻 C
字号:
/*浏览投票人简介*/
BrowseIntro()
{
    FILE *fp = NULL;        /*定义指向文件的指针*/
    candidate TmpS;          /*定义进行操作时存放结构体变量的*/

    char DataFile[40] = "";
    /*====输入存放候选人简介信息的文件名====*/
    printf("\n please input file name to browse,end with enter.");
    printf("\n Notice:Name of file can't exceed 8 characters.suffix can't exceed 3 characters,part of exceed will be discarded.\n");
    gets(DataFile);

   /*如用户没有输入,则循环提示用户输入*/
    while(*DataFile == ('\0'))
    {
        printf("\n please input new file name to store data,end with enter.");
        printf("\n Notice:Name of file can't exceed 8 characters,suffix can't exceed 3 characters.part of exceed will be discarded.\n");
        gets(DataFile);
    }
    printf("Content as follow:\n");
    /*打开候选人信息文件*/
    fp=fopen(DataFile,"rb");
    if (fp == NULL)
    {
        printf("\nOpen file%sfail!End with any key \n",DataFile);
        perror("Open file fail");
        getch();
        exit(1);
    }
    /*显示候选人信息*/
    printf("\nNumber\tName\tintro\n");
    while(fread(&TmpS,sizeof(candidate),1,fp) != (int)NULL)
    {
        printf("\n%ld     \t%s\t%s\n",TmpS.Number,TmpS.Name,TmpS.intro);
    }
    fclose(fp);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -