C语言文件问题,谁来救救我!!!!

来源:百度知道 编辑:UC知道 时间:2024/05/20 19:29:44
有二个程序,第一是我做了一个文件,把一堆数据存入这个文件,然后,我在第二个程序把第一个文件的数据调出来,存入数组中,进行排序操作,当第一个程序运行完后,我在桌面看到了一个文件,我以TC方式打开后,CTRL+F5看到的是乱七八糟的东西,以记事本的方式打开也是看到的乱七八糟的东西,??????
而且运行第二个程序,出现的是一堆0000,实在搞不清楚,就麻烦拉.
这两个程序对我非常的重要!!!
我的上机书上都有文件操作,那书,本来有盘,实际没了,所以,数据都要自己做,.
所以上面二个程序很重要呀!!!
谢谢!
#include<stdio.h>
main()
{ FILE *fp;
int i,j;
float x;
fp=fopen("a.t","wb");
if(fp==NULL){printf("can not open the file\n");exit(0); }
printf("\ninput 10 data into a.t:") ;
for(i=0;i<10;i++)
{scanf("%d",&x) ;
fwrite(&x,4,1,fp) ;
} fclose(fp) ;
}

************************************************************
#include<stdio.h>
#include<string.h>
int a[10] ;
void readdat()
{FILE *in;int i; in=fopen("a.t","r") ;
for(i=0;i<=9;i++) fscanf(in,"%d",&a[i

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void main()
{ FILE *fp;
int i;
int x;
fp=fopen("a.t","w+");
if(fp==NULL){printf("can not open the file\n");exit(0); }
printf("\ninput 10 data into a.t:") ;
for(i=0;i<10;i++)
{
scanf("%d",&x) ;
fprintf(fp,"%d ",x);
}
fclose(fp) ;
}

//*************************************************************
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int a[10] ;
void readdat()
{FILE *in;int i; in=fopen("a.t","r+") ;
for(i=0;i<=9;i++) fscanf(in,"%d",&a[i]) ;fclose(in) ;
}
void jssort()
{int t, i,j;
for(i=0;i<9;i++) for(j=i+1;j<10;j++) if(a[i]>a[j]) {t=a[i];a[i]=a[j];a[j]=t;}
for(i=0;i<=9;i++) printf("%