C语言完美演绎9-24

/* 范例:9-24 */

#include <fcntl.h>

#include <io.h>

#include <stdio.h>

#include <stdlib.h>

void main(int argc,char *argv\[\])

{

int file1,file2;

char buf512;

if((file1 = open(argv1,O_RDONLY))==-1)

{

printf("Read file %s Error!\n",argv1);

exit(1);

}

if((file2 = open(argv2, O_WRONLY|O_CREAT))==-1)

{

printf("Create file %s Error!\n",argv2);

exit(1);

}

while(read(file1,buf,512)>0)

write(file2,buf,512);

close(file1);

close(file2);

}

程序执行结果:

D:\TC>p9-24 xx.txt out.txt

相关推荐
程序猿编码10 分钟前
不用 PyTorch!纯 C 实现 N 维张量 + 反向传播,完成手写数字识别训练
c语言·人工智能·pytorch·神经网络·卷积神经网络·大模型推理
Navigator_Z2 小时前
LeetCode //C - 1269. Number of Ways to Stay in the Same Place After Some Steps
c语言·算法·leetcode
垆边人似月.2 小时前
华为机考题:矩阵中的最长递增路径
c语言·c++
free-elcmacom3 小时前
手撕 memcpy 和 memmove:从字节级拷贝到内存重叠的终极较量
c语言·开发语言·青少年编程·visual studio code·visual studio
程序员_小兵3 小时前
PCIe Switch Fabric 技术解析
服务器·c语言·嵌入式硬件·php·fabric
凉茶钱4 小时前
【C++】动态内存管理完整解析:从内存划分到 new delete 底层原理
c语言·开发语言·c++·内存管理·动态内存
cu1434 小时前
细谈GM8775C的具体功能和应用
c语言·c++·人工智能·嵌入式硬件
@yanyu66619 小时前
C编译器安装与第一个C程序
c语言·开发语言
山下梅子酒22519 小时前
洛谷-入门-B2070
c语言