通用和斯巴鲁品牌历史:C语言文件输出出现乱码!

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/05 00:54:59
#include "stdafx.h"
#include "stdio.h"
#include "string.h"
#include "stdlib.h"//system的头文件

#define SIZE 100
void input()
{
int i,amount,c,j;
char ask;
system("cls");

for (i=0;i<80;i++)
printf ("#");
printf ("\n\t\t\t欢迎使用火车票信息录入系统。\n\n");
for (i=0;i<80;i++)
printf ("#");

struct ticket
{
char num[8];//车次
char start[8];//起点
char finish[8];//终点
char time[10];//出发时间
char price[8];//价钱
int seat;//座位
char style[12];//类型
}t[SIZE];//定义一个结构体。

for(;;)
{ printf ("您要录入多少条火车票信息?");
scanf ("%d",&amount);
if (amount>100||amount<0)
{
printf ("\n请输入一个1到100的数字!!!\n\n");
continue;//如果要录入的信息数目不在1-100之间便提示错误,并重新录入
}
else
break;//如果要录入的信息数目在1-100之间便跳出循环转到下一语句继续运行。
}

for (c=0;c<SIZE;c++)

if (t[c].num==NULL)
{printf ("按Y返回主菜单,按其他键退出\n");
scanf ("%c",&ask);
if (ask=('Y'||'y'))
return;
else
exit(0);
}
for (i=0;i<amount;i++)
{
printf ("\n请输入第%d条信息!\n",i+1);//提示输入的是第几条信息
printf ("\n车次(如K241):");
scanf ("%s",&t[i].num);//提示并且输入车次
printf ("起点(如广州东站):");
scanf ("%s",&t[i].start);//提示并且输入起点
printf ("终点(如广州站):");
scanf ("%s",&t[i].finish);//提示并且输入终点
printf ("出发时间(如06:30):");
scanf ("%s",&t[i].time);//提示并且输入起点出发时间
printf ("价钱(如250):");
scanf ("%s",&t[i].price);//提示并且输入价格
printf ("座位(如16):");
scanf ("%d",&t[i].seat);//提示并且输入座位
printf ("类型(如硬/学或者卧/普):");
scanf ("%s",&t[i].style);//提示并且输入类型

printf("\n您的本次输入的信息为:\n\n");
printf("车次 起点\t 终点\t 出发时间 价钱 座位 类型\n");
printf("%s%s%s%s%s%d%s\n\n",t[i].num,t[i].start,t[i].finish,t[i].time,t[i].price,t[i].seat,t[i].style);
//对每一条录入的信息进行报表
printf ("按“r”重新输入,按“b”返回,按“q”退出,按其他键保存并继续。\n");
//提示用户的下一步操作
fflush(stdin);
scanf ("%c",&ask);
switch (ask)
{
case 'r':i--;break;
case 'b':system("cls");return;
case 'q':exit(0);
default:{
FILE *fp;
if ((fp=fopen("ticket","a+"))==NULL)
printf ("文件打开出错!");
for (j=i;j<i+1;j++)
if (fwrite(&t[j],sizeof (struct ticket),1,fp)!=1)
printf("文件写入错误");
fclose (fp);
}
printf("\n火车票信息储存成功!\n\n");break;//输入每条信息保存,防止以外关机,导致信息流失
}
}
}
出现很多烫字!!!!
开发环境就是VC

你用什么开发工具啊 是不是不能输出汉字的啊

vc里试试