?? file.c
字號:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define NUM 50
void main(void)
{
int source1[NUM];
int source2[NUM];
int i=NUM,j=NUM;
FILE *fp;
srand(time(NULL));
for(i=0;i<NUM;i++)
{
source1[i]=rand()%2000;
}
/****************************************/
/*寫文件 data1.dat*/
fp=fopen("e:\\data1.dat","wb");
if(fp==NULL)
{
printf("the file cannot be open.\n");
exit(0);
}
fwrite(source1,sizeof(int),NUM,fp);
fclose(fp);
for(j=0;j<NUM;j++)
{
source2[j]=rand()%2000;
}
/********************************************/
/*寫文件 data2.dat*/
fp=fopen("e:\\data2.dat","wb");
if(fp==NULL)
{
printf("the file cannot be open.\n");
exit(0);
}
fwrite(source2,sizeof(int),NUM,fp);
fclose(fp);
/********************************************/
printf("File write success!\n");
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -