C++完美演绎 经典算法 如 /* 头文件:my_Include.h */ #include <stdio.h> /* 展开C语言的内建函数指令 */ #define PI 3.141
源代码在线查看: 9-24.txt
/* 范例:9-24 */
#include
#include
#include
#include
void main(int argc,char *argv[])
{
int file1,file2;
char buf[512];
if((file1 = open(argv[1],O_RDONLY))==-1)
{
printf("Read file %s Error!\n",argv[1]);
exit(1);
}
if((file2 = open(argv[2], O_WRONLY|O_CREAT))==-1)
{
printf("Create file %s Error!\n",argv[2]);
exit(1);
}
while(read(file1,buf,512)>0)
write(file2,buf,512);
close(file1);
close(file2);
}
程序执行结果:
D:\TC>p9-24 xx.txt out.txt