reading a character from one file writing it twice in another file

 #include <stdio.h>


int main(){
FILE *ptr1,*ptr2;
ptr1=fopen("file1.txt","r");
ptr2=fopen("file2.txt","w");
char c;
c=fgetc(ptr1);
while(c!=EOF)
{
    fputc(c,ptr2);
    fputc(c,ptr2);

    c=fgetc(ptr1);
   

}
fclose(ptr1);
fclose(ptr2);
 return 0;
}

Comments

Popular posts from this blog

snake game Version-2 (using random number)

allocating dynamic memory using calloc

store a table in dynamic array and then change the size of array dynamically to store more numbers