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

相关推荐
Zwawa13 小时前
屏幕不止一种:OLED、LCD1602字符屏、TFT/IPS图形屏和串口屏怎么用,这与TTY和PTY又有什么关系
c语言·单片机·嵌入式
Fruiticecake13 小时前
C 程序员速通现代 C++(一):lambda、std::function、移动语义与智能指针
c语言·c++
田甲13 小时前
做一款 Type-C 母座读卡器:GL3224 双卡方案实测
c语言·开发语言
·present·18 小时前
CSAPP(lecture 13_02 Linking)
c语言·c++
wuyk5551 天前
Keil工具链-第05讲-启动文件与__main到底做了什么
c语言·stm32·单片机·嵌入式硬件·物联网
Navigator_Z2 天前
LeetCode //C - 1317. Convert Integer to the Sum of Two No-Zero Integers
c语言·算法·leetcode
冻柠檬飞冰走茶2 天前
字母移动游戏题解:贪心求最长可保留连续子串(附 C 实现)
c语言·开发语言·数据结构·算法·动态规划
Hhy_11072 天前
《C++深度解构06》手撕 string —— 从底层内存管理到深浅拷贝彻底吃透
c语言·开发语言·c++·学习·visual studio
曦樂~2 天前
Cpp面筋
c语言·c++
HUANGZHENXUAN1233 天前
最大子矩阵和:从 O(n⁴) 到 O(n³) 的列压缩 + Kadane
c语言·前端