Merge two files into third file

Write a program to merge two files into the third file.

#include<stdio.h>
void Merge_two_files(FILE*,FILE*,FILE*);
int main()
{
	char first[32],second[32];
	FILE *f1,*f2,*f3;
	printf("Enter first file name = ");
	scanf("%[^\n]",first);
	printf("Enter second file name = ");
	scanf(" %[^\n]",second);
	f1 = fopen(first,"r");
	f2 = fopen(second,"r");
	if(f1 == NULL || f2 == NULL)
	{
		printf("file is not present in present working directory\n");
		return 0;
	}
	Merge_two_files(f1,f2,f3);
	return 0;
}
void Merge_two_files(FILE *p1,FILE *p2,FILE *p3)
{
	char ch;
	p3 = fopen("result","w");
	while((ch = fgetc(p1)) != EOF)
	{
		fputc(ch,p3);
	}
	while((ch = fgetc(p2)) != EOF)
	{
		fputc(ch,p3);
	}
	fclose(p1);
	fclose(p2);
	fclose(p3);
}

Output

Enter first file name = d1
Enter second file name = d2
cat d1
Lot To Learn
BlackBerry
Iphone
Incredible India
cat d2
Lot To Learn
BlackBerry
Iphone
Incredible India
cat result
Lot To Learn
BlackBerry
Iphone
Incredible India
Lot To Learn
BlackBerry
Iphone
Incredible India