Writing character into File:
fputc(): A pre-defined function is used to write character into file.
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; } |