#include <windows.h>
#include <stdio.h>
#define MAX_NUM 260
#define READ_NUM 1024
int main()
{
char FileName[MAX_NUM] = "temp.txt ";
char Buffer[READ_NUM] = " ";
FILE* Source = NULL;
FILE* Dest = NULL;
int i = 0;
size_t SzByte = 0; //all bytes of File
size_t SzRead = 0; //read bytes from File
Source = fopen(FileName, "r+b ");
Dest = fopen( "q.txt ", "w+b ");
if((Source == NULL) || (Dest == NULL))
{
printf( "Open file failed \n ");
}
fseek(Source, 0, SEEK_END);
SzByte = ftell(Source);
fseek(Source,0,SEEK_SET);
i = SzByte/READ_NUM;
for(int j=0;j <(i+1);j++)
{
SzRead = fread(Buffer,sizeof(char),READ_NUM,Source);
if(SzRead == 0)
{
printf( "read file failed\n ");
}
fprintf(Dest, "%s ",Buffer);
}
fclose(Source);
fclose(Dest);
return 0;
}
#include <stdio.h>
#define MAX_NUM 260
#define READ_NUM 1024
int main()
{
char FileName[MAX_NUM] = "temp.txt ";
char Buffer[READ_NUM] = " ";
FILE* Source = NULL;
FILE* Dest = NULL;
int i = 0;
size_t SzByte = 0; //all bytes of File
size_t SzRead = 0; //read bytes from File
Source = fopen(FileName, "r+b ");
Dest = fopen( "q.txt ", "w+b ");
if((Source == NULL) || (Dest == NULL))
{
printf( "Open file failed \n ");
}
fseek(Source, 0, SEEK_END);
SzByte = ftell(Source);
fseek(Source,0,SEEK_SET);
i = SzByte/READ_NUM;
for(int j=0;j <(i+1);j++)
{
SzRead = fread(Buffer,sizeof(char),READ_NUM,Source);
if(SzRead == 0)
{
printf( "read file failed\n ");
}
fprintf(Dest, "%s ",Buffer);
}
fclose(Source);
fclose(Dest);
return 0;
}