CO-filehandling Notes
CO-filehandling Notes
WhatsApp PDF) DOWNLOAD... Kimetsu no Yaiba E... 9 Tokyo Ghoul Ep. 1-... 9 AOT-OVA Tolkyo Ghoul(Sub)
Types of Files
When dealing with files, there are two types of files you should knoww about:
Text files
Binary files
1. Text files
Text files are the normal .bt files. Can easily create text files using any simple text editors such as Notepad.
When you open those files, you'll see all the contents within the file as plain text. You can easily edit or delete the
contents.
They take minimum effort to maintain, are easily readable, and provide the least security and takes bigger storage
space.
2. Binary files
Binary files are mostly the .bin fhles in your computer.
Instead of storing data in plain text, they store it in the binary form (0's and 1's).
They can hold a higher amount of data, are not readable easily, and provides better security than texct files.
file handling insert Format Sicde Arrange Tocls Help Sideshow)s Share
File dt V
- Background Layout Theme Transition
2
File Operations
"In C, you can perform four major operations on files, either text or
binary:
"Creating a new file
"Opening an existing file
"Closinga file
"Reading from and writing information to a file
bGoogle Slides X
docs.google.com/presentation/d/1b06n6yilt6q TiNPDqNLPWRewGKQgCY1V/edit#slide=id.p5 Incognito (2)
Open for append in binary mode. If the file does not exist, it will be
ab Data is added to the end of the file. created.
Open for both reading and writing in If the file does not exdst, fopen)
rb+ returns NULL.
binary mode.
at Open for both reading and If the file does not exist, it
appending. will be created.
ab+ Open for both reading and If the file does not exist, it
appending in binary mode. will be created.
Siceshow ) Share
Insert Format Side Arrange Tools Help
Closing a File
"The file (both text and binary) should be closed after reading/writing.
"Closing afile is performed using the fclose() function.
"fclose(fptr); Here, fptr is a file pointer associated with the file to be
closed.
Hocs.WhatsApp
9 google.com/presentaDOWNLOAD.
[POF) tion/d/1b06n6yi
.
lt6q TiNPDqNLPWRewGKQgCYIV/edt#slide-=id.pt1
Kimetsu no Yaiba E... S Tokyo
Ghoul Ep.1-... TY
Incognito (2)
AOT-OVA Tolkyo Ghoul (Sub)..
ert Format Side Arrange
Tools Help
sliceshow 3 Share
1 Background Layout Theme ransition
15 printf("Error ! "):
exit(1):
fprintf( fptr."xd,nun):
fclase(fptr):
24
25 return 0;
26 )
docs.google.com/presentation/d/1 b06nóyilt6qliNPDqNLPWRewGKQgCYIV/edit#side=id.p13
(PDF] DOWNLOAD... Kimetsu no Yaiba E... Tolyo Ghoul Ep. 1-... P AOT-OVA Tokyo Ghoul (Sub).
WhatsApp
Slideshow & Share
Ntaion/dMb06nóyilt6qTiNPDqNLPWRevwGKQgCY1V/edit#slide=1d.p14
DOWNLOAD..
Arrange Tocls Help
1
Kimetsu no Yaiba E...
Example 3: Write to
#include cstdio.b a binary file using furite()
Binclude <stdlib.h
struct threetum
int nt., n2, n3:
int maln()
int n:
struct threelum nun:
FILE fptr:
1f CCfptr
12 fopen("C:\\program, bin", "wb))
printf("Error1 opening file"): ULL)
1 Program exits if the file pointer returns NULL.
exit(1):
for(n 1; ns 5; **n)
num.nn:
num,n2 $n:
num.n3 5n 1;
fwrite( &nun, sizeof(struct threetum). 1, fptr):
felose(fptr):
PTX Siceshow &Share
fle handling
insert Format Slde Arrange Tools Help
File Edt Vi
18ackground Layout Theme Transition
int n;
struct threeun nun;
13 FILE *fptr:
for (n 1: n< 5: n)
fread(&nun, sizeof(struct threetlun), 1. fptr):
printf(at: 3d\tn2: ita3: d, num,nl, num,n2, num.n3):
fclose( fptr):
return 0:
DOWNLOAD.. 6 Kimetsu no Yaiba E. edtestde=id.p17
Tokyo Ghoul Ep. 1-.. Incognito (2
Insert Format Side Arrange Tocls
Help
AOT-OVA Tolkyo Ghoul (Sub).
G
ackground Layout Theme Transition
Sliceshow D 8 Share
Syntax of fseek()
fseek(FlLE
The first
*streanm, long int offset, int
whence);
parameter stream is the pointer to the file. The second
the recordto be found, and the parameter is the position of
third parameter specifies the location where the offset starts.
SEEK
SET Starts the offset from the
beginning of the file.
Starts the offset from the end of
SEEK_END the file.