logo

CuriousTab

CuriousTab

Discussion


Home Technical Questions Programming Comments

  • Question
  • Write a c program to copy a data of file to other file.


  • Correct Answer
  • #include int main(){ FILE *p,*q; char file1[20],file2[20]; char ch; printf("\nEnter the source file name to be copied:"); gets(file1); p=fopen(file1,"r"); if(p==NULL){ printf("cannot open %s",file1); exit(0); } printf("\nEnter the destination file name:"); gets(file2); q=fopen(file2,"w"); if(q==NULL){ printf("cannot open %s",file2); exit(0); } while((ch=getc(p))!=EOF) putc(ch,q); printf("\nCOMPLETED"); fclose(p); fclose(q); return 0; } 


  • Programming problems


    Search Results


    • 1. Write a program for matrix multiplication in c
    • Discuss
    • 2. Write a c program for binary search.
    • Discuss
    • 3. Write a c program for merge sort.
    • Discuss
    • 4. Write a c program for insertion sort.
    • Discuss
    • 5. Write a c program for quick sort.
    • Discuss
    • 6. What will be output of following c code? void main() { struct india { char c; float d; }; struct world { int a[3]; char b; struct india orissa; }; struct world st ={{1,2,3},'P','q',1.4}; clrscr(); printf("%dt%ct%ct%f",st.a[1],st.b,st.orissa.c,st.orissa.d); getch(); }
    • Discuss
    • 7. What is the output of this C code? #include void m() { printf("hi"); } void main() { m(); }

    • Options
    • A. hi
    • B. Run time error
    • C. None
    • D. Varies
    • Discuss
    • 8. The output of the code below is #include int *m() { int *p = 5; return p; } void main() { int *k = m(); printf("%d", k); }

    • Options
    • A. 5
    • B. Junk value
    • C. 0
    • D. Error
    • Discuss
    • 9. What would be the output of the following program? main() { extern int i; i = 20; printf( "%d", sizeof(i) ); }
    • Discuss
    • 10. What is the difference between the following declarations? extern int fun(); int fun();
    • Discuss


    Comments

    There are no comments.

Enter a new Comment