Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
13 views2 pages

FILES

Uploaded by

sai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

FILES

Uploaded by

sai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

FILES

FILE--> STORAGE PLACE TO STORE SOME DATA IN THE COMPUTER

File is collection of data stored in a computer

2 types of files
text file --->ASCII FILE --> Text file contains ascii values of digits,
symbols ,characters
binary file ---> 0's and 1's

FILE OPERATIONS
Closing a file
opening a file
reading data from a file
writing data to the file

FILE *ptr;

*fptr=fopen( " file.txt " ," mode " );

FILE MODES

r ---------> read mode

w----------> write mode

a ---------> append mode


r+ --------> read+write
w+ ------> write +read
a+ ------> append + read

...............................................

FILE HANDLING FUNCTIONS

fopen() --> to open a file


fclose() ----> to close a file
getc() -------> reading a character from a file

getw() -----> read integer from a file

fprintf() ---> prints or writes data to a file

fscanf()----> scan data from the file

putc ()---> to write a character to a file

putw()---->to write a integer to a file

EOF----> end of the file


...................................................................................
...................................................................................
.

main()
{
FILE *fp;
char ch ;
fp=fopen("abc.txt ", "w");
printf("enter data ");
while(ch!=EOF )
{

ch=getchar();
putc(ch,fp);

}
fclose(fp);
}

You might also like