| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 565 人关注过本帖
标题:编一个图书信息管理管理系统,现在遇到一个问题卡住了,求解
取消只看楼主 加入收藏
猪自轻
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2012-12-11
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:1 
编一个图书信息管理管理系统,现在遇到一个问题卡住了,求解
现在的问题是将在控制台输入的数据读出到文档(txt格式)时,出现了乱码,但是出现乱码的又只是数字出现乱码,字母没有出现乱码,求解答
现在将那个部分的函数代码放上来,望大神们帮忙解答解答一下吧,谢谢了~~

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <windows.h>
#include <ctype.h>
struct Books
{
    int loginID,sortnum;
    float price;
    long time;
    char bkname[50],cbname[50],wname[50];
    struct books *next;
};
typedef struct Books Book;
Book books[20];

void homepage();
void adm_list();
void book_login();

void main()
{
    char a;
    int i;
    printf("\n\n\t\t\t*****************************\n");                        
    printf("\t\t\t   欢迎使用图书信息管理系统\n");                                    
    printf("\t\t\t*****************************\n\n\n");
    printf("--------------------------------------------------------------------------------\n");
    printf("\t             <按回车键进入系统>\t");
    a=getchar();
    system("cls");
    do{
        printf("\n\n            Management for Books' imformations:\n");
        printf("\n\t        1.Input the book's information:\n");
        printf("\t        2.Browse the book's information:\n");
        printf("\t        3.Search the book's information:\n");
        printf("\t        4.Delete the book's information:\n");
        printf("\t        5.Change the book's information:\n");
        printf("\t        6.EXIT!\n");
        printf("\n\t        Please input your choice:");
        scanf("%d",&i);
        system("cls");
        if(i!=1 && i!=2 && i!=3 && i!=4 && i!=5 && i!=6)
        {
            printf("\n\tInput error!\n");
            printf("\tEnter any key to start again!");
            a=getchar();
        }
    }while(i!=1 && i!=2 && i!=3 && i!=4 && i!=5 && i!=6);
    switch(i)
    {
        case 1: book_login();  break;                                    
        case 2: book_view(); break;                                         
        case 3: book_search(); break;                                
//        case 4: del(); break;
//        case 5: change(); break;
        case 6: logout(); break;
    }
}
/*----------------------------------------------------------------*/
void homepage()
{
    char i;
    printf("\n\n\t\t\t*****************************\n");                        
    printf("\t\t\t    图书信息管理系统\n");                                    
    printf("\t\t\t*****************************\n\n\n");
    printf(" -------------------------------------------------\n");
    printf("\t<按任意键进入>\n\t");
    i=getchar();
}
/*----------------------------------------------------------------*/
void adm_list()
{
    void book_login();
    void book_view();
    void book_search();
    void logout();
    void del();
    void change();
    int i;
    char a;
    do{
        printf("\n\n            Management for Books' imformations:\n");
        printf("\n\t        1.Input the book's information:\n");
        printf("\t        2.Browse the book's information:\n");
        printf("\t        3.Search the book's information:\n");
        printf("\t        4.Delete the book's information:\n");
        printf("\t        5.Change the book's information:\n");
        printf("\t        6.EXIT!\n");
        printf("\n\t        Please input your choice:");
        scanf("%d",&i);
        system("cls");
        if(i!=1 && i!=2 && i!=3 && i!=4 && i!=5 && i!=6)
        {
            printf("\n\tInput error!\n");
            printf("\tEnter any key to start again!");
            a=getchar();
        }
    }while(i!=1 && i!=2 && i!=3 && i!=4 && i!=5 && i!=6);
    switch(i)
    {
        case 1: book_login();  break;                                    
        case 2: book_view(); break;                                         
        case 3: book_search(); break;                                
//        case 4: del(); break;
//        case 5: change(); break;
        case 6: logout(); break;
    }
}
void book_login()
{
    struct Books Book;
    void adm_list();
    int i=0,j;
    FILE *fp;
    char a;
    struct Books book_taxi[30];
    printf("\n\n\n\t        ---Please enter book's information---\n\n");
    printf("\tLogin ID:");
    scanf("%d",&Book.loginID);
    printf("\n\tBook name:");
    scanf("%s",Book.bkname);
    printf("\n\tWriter's name:");
    scanf("%s",Book.wname);
    printf("\n\tSort number:");
    scanf("%d",&Book.sortnum);
    printf("\n\tPublishing company:");
    scanf("%s",Book.cbname);
    printf("\n\tPublishing time:");
    scanf("%ld",&Book.time);
    printf("\n\tBook's Price:");
    scanf("%f",&Book.price);
    system("cls");
    if(fp!=NULL)
    {
        for(j=0;j<i;j++)
        {
            fprintf(fp,"%d\t",Book.loginID);
            fprintf(fp,"%s\t",Book.bkname);
            fprintf(fp,"%s\t",Book.wname);
            fprintf(fp,"%d\t",Book.sortnum);
            fprintf(fp,"%s\t",Book.cbname);
            fprintf(fp,"%ld\t",Book.time);
            fprintf(fp,"%f\t",Book.price);
            fclose(fp);            
        }
        
    }
    fp=fopen("book.txt","r");
    if(fp!=NULL)
    {
        for(j=0;j<i;j++)
        {
            fscanf(fp,"%d\t",&Book.loginID);
            fscanf(fp,"%s\t",Book.bkname);
            fscanf(fp,"%s\t",Book.wname);
            fscanf(fp,"%d\t",&Book.sortnum);
            fscanf(fp,"%s\t",Book.cbname);
            fscanf(fp,"%ld\t",&Book.time);
            fscanf(fp,"%f\t",&Book.price);
        }
    }
          if((fp=fopen("book.txt","r"))==NULL)
    {
        fp=fopen("book.txt","w");
    }
    else
    {
        fclose(fp);
        fp=fopen("book.txt","a");
    }
    fwrite(&Book,sizeof(struct Books),1,fp);
    fclose(fp);
    printf("\n\n\n\n\t     The information has been stored,enter your choice to continue!\n\n");
    printf("\n");
    a=getchar();
    adm_list();
    fclose(fp);
}
搜索更多相关主题的帖子: 管理系统 include price 
2013-03-27 16:09
猪自轻
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2012-12-11
收藏
得分:0 
各位大神,帮帮忙吧,谢谢~~
2013-04-03 11:31
快速回复:编一个图书信息管理管理系统,现在遇到一个问题卡住了,求解
数据加载中...
 
   



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

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