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.

48 comments:

Anonymous said...

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

Anonymous said...

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"

Anonymous said...

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

Anonymous said...

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.

Anonymous said...

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

Anonymous said...

i want to write c Program that can search strings

Anonymous said...

learn basic of c programming from programmingcampus

Anonymous said...

why we write FILE in caps

Unknown said...

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

Unknown said...

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

Sukanta Bala said...

"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..

Anonymous said...

why we use capital letters FILE to use it what is this

Anonymous said...

hurry up plzzz

Unknown said...

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

Anonymous said...

how to stop writing the test

Anonymous said...

you have to create file in binary format

Anonymous said...

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.

Anonymous said...

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???

Unknown said...

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

Anonymous said...

so how to create a file in binary format???

Unknown said...

it means write in the file bro

Unknown said...

how to compare data that stored in a single File???????????????

Unknown said...

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

Anonymous said...

because FILE is an string that performs operation on files.

Unknown said...

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

Meghnath said...

putc(ch,fp); // wat is this used for?

Meghnath said...

can I get a detailed Explanation please...

Unknown said...

how will the program close

Unknown said...

ctrl+z

Unknown said...

ctrl+z

Anonymous said...

Why is the program not ending even when enter is pressed?

abcdef said...

How to compare the text/data within a file?

Unknown said...

in above program EOF will not work bcz it will not terminate the program itself and due to this file is not written

Unknown said...

in above program EOF will not work bcz it will not terminate the program itself and due to this file is not written

Anonymous said...

And how can it be fixed?

Unknown said...

how to create a file generating 1000 random numbers and bubble sort it to place the result in another file?

KD said...

using function that takes a string and a number between 0 and 9 as
parameters, and displays the string that many times, and returns its length in c programming.


Unknown said...

how to create table in file handling using c

Unknown said...

how to create a c program in array

Unknown said...

using array, display the answer of multiplying the number of the first raw with number of the second raw.display the result on the blank cell.

example; 1x1=1,1x2=2,2x2=4

sravani said...

its writing mode indicator

sravani said...

but my compiler says it is a undefined symbol! y like that

aman said...

cans ome1 plss give me c program for
to receive a sentence from user store it ina file and display the file contents

Anonymous said...

Hi,I have a question.. When I wrote in my file ''Number.txt'' a few numbers (1,2,3,4,5,6).How can I find their max in min value in c programm? I mean how can I work with that data inside c ? Pls help

Unknown said...

how it close???ehen i press enter but the file doesn't create...what is the solution???please tell me

Unknown said...

But how I can do all the three I mean read copy and delete in on program ??

Unknown said...

Write a program

Peter Johnson said...

This is really great informative blog. Keep sharing.I want to share about Agro Fertilizer Company in India