当前位置:网站首页>File compositor

File compositor

2022-06-11 03:06:00 shlyyy


One 、 demonstration

1. Input file name

 Insert picture description here

2. Check out the newly generated NewPng file

2.1 NewPng.png

 Insert picture description here
 Insert picture description here

2.2 NewPng.rar

 Insert picture description here

 Insert picture description here

Example :

Two 、 Source code

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>


int Sub_3()
{
    
	char ch, pic_name[20], file_name[20], finish_name[20];
	FILE* f_pic, * f_file, * f_finish;
	printf(" Please enter the name of the picture you want to compose \n");
	printf(" picture :");
	scanf("%s", pic_name);
	printf(" file :");
	scanf("%s", file_name);
	printf(" Born into :");
	scanf("%s", finish_name);
	if (!(f_pic = fopen(pic_name, "rb")))
	{
    
		printf("Cannot open the picture %s !", pic_name);
		return 0;
	}
	if (!(f_file = fopen(file_name, "rb")))
	{
    
		printf("Cannot open the file %s !", file_name);
		return 0;
	}
	if (!(f_finish = fopen(finish_name, "wb")))
	{
    
		printf("Cannot open the file %s !", finish_name);
		return 0;
	}
	while (!(feof(f_pic)))// Returns a non at the end of the file 0 value  
	{
    
		ch = fgetc(f_pic);
		fputc(ch, f_finish);
	}
	fclose(f_pic);
	while (!(feof(f_file)))
	{
    
		ch = fgetc(f_file);
		fputc(ch, f_finish);
	}
	fclose(f_file);
	fclose(f_finish);

}
int main()
{
    
	Sub_3();

	system("pause");
    return 0;
}

Be careful : file name ( route ) It's using scanf Function get from console , So there can be no spaces , Otherwise, it will be truncated .


Study

The basic operation of the file

原网站

版权声明
本文为[shlyyy]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206110242502969.html