⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test7_2.txt

📁 linux under the C programming which complementary with the book of <linux under the C programming
💻 TXT
字号:
#include <sys/types.h>
#include <stdio.h>

#define BUF_SIZE 1024

int main(void)
{
    	char buf[BUF_SIZE];
    	FILE *source, *backup;

    	if(!(source=fopen("source.dat", "r")))
    	{
        	printf("Error in opening file.\n");
       		exit(1);
    	}

    	if(!(backup=fopen("backup.dat", "w")))
    	{
        	printf("Error in creating file.\n");
       		exit(1);
    	}
    	while(fread(buf, sizeof(buf), 1, source)==1)
    	{
        	if(fwrite(buf, sizeof(buf), 1,backup))
        	{
            		printf("Error in wrinting file.\n");
            		exit(1);
        	}
    	}

    	if(ferror(source)==0)
	{
    		printf("Error in reading file.\n");
    		exit(1);
	}

    	if(!fclose(source))
    	{
        	printf("Error in close file.\n");
        	exit(1);
    	}
    	if(fclose(backup))
	{
        	printf("Error in close file.\n");
        	exit(1);
    	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -