CREATE A FILE AND STORE DATA IN IT IN C PROGRAM






C program to create a file

C program to write to a file

C program to open a file


#include<stdio.h>
int main(){
FILE *fp;
char ch;
fp=fopen("file.txt","w");
printf("\nEnter data to be stored in to the file:");
while((ch=getchar())!=EOF)
putc(ch,fp);
fclose(fp);
return 0;
}










2.  Write a c program to delete a file.
3. Write a c program to copy a file from one location to other location.
6. Write a c program which writes string in the file.

26 comments:

  1. IS IT POSSIBLE TO GET SOLUTION TO THESE QUESTIONS
    1.Write a program to store names and marks in a file.
    2.Retrieve data from the file

    ReplyDelete
    Replies
    1. you have to create file in binary format

      Delete
    2. so how to create a file in binary format???

      Delete
  2. pllllllzzzzzzzzzzz give me solution for this question..........????????????????
    write a program to creat a tex "biodata.txt" file which contains pegno and name of a student also read a text file "biodata.txt"

    ReplyDelete
  3. hi,,i have a question,,why u used return value,,we dont need int,we can use void instead of that,,could u please explain for me it's reason?

    ReplyDelete
    Replies
    1. as the function is of integer type, the function must have to return some value.

      Delete
  4. I want to write a program that will extract data from the the database and save into a file. Thanks in advance

    ReplyDelete
  5. Write a C program that asks from the user his basic details (name, course, year, birthday, etc.). Write these details into an external file. Make sure that the old contents of the file will not be discarded. The user will be prompted whether he still wants to add data or to exit the program.

    ReplyDelete
  6. to sort contents of file based on line no..?can u gve program plz

    ReplyDelete
  7. i want to write c Program that can search strings

    ReplyDelete
  8. learn basic of c programming from programmingcampus

    ReplyDelete
  9. why we write FILE in caps

    ReplyDelete
    Replies
    1. because FILE is an string that performs operation on files.

      Delete
  10. can any one know about how to call string.h file in c

    ReplyDelete
  11. fp=fopen("file.txt","w");
    what does mean by this "W"

    ReplyDelete
    Replies
    1. it means write in the file bro

      Delete
  12. "w" means write mode. You can write numbers or data on that file. and "r" means read mode. You can't write numbers or data on that file but you can only read that file..

    ReplyDelete
  13. why we use capital letters FILE to use it what is this

    ReplyDelete
  14. hurry up plzzz

    ReplyDelete
  15. cant write text in localhost bcos of permission
    pls tell me how to write program for give writing permission..

    ReplyDelete
  16. how to stop writing the test

    ReplyDelete
  17. Please Give Solution for this
    Que: WAP to store n integer values in a file and sort it in ascending order line by line without using any array, linked lists or any other dynamic locations.

    ReplyDelete
  18. hi frndz..
    create a file and extend multiple file within that and perform all kinds of operationss such as copy delete and so.. how to do this???

    ReplyDelete
  19. Hi Friends,
    please share code for this program:
    To find Leaders and Block of Compiler Optimization through file handling?

    ReplyDelete
  20. how to compare data that stored in a single File???????????????

    ReplyDelete
  21. how can i do it this program when the user types 'exit' it should stop the program??

    ReplyDelete