fputc():
- A pre-defined function is used to write the data character by character into file.
- The prototype is :
void fputc(int x, FILE* stream);
#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...\n");
fclose(dest);
fclose(src);
}
return 0;
}