Write a program in C to copy a file in another name

Previous
Next
#include<stdio.h>
int main()
{
	FILE *src, *dest;
	int ch;
	src = fopen("code.c", "r");
	dest = fopen("output.txt", "w");
	if(src != NULL)
	{
		while((ch = fgetc(src)) != EOF)
		{
			fputc(ch, dest);
		}
		printf("Data copied from source folder to destined folder\n");
		printf("Please open and check the destined file\n");
		fclose(dest);
		fclose(src);
	}
	return 0;
}
Previous
Next

Courses Enquiry Form