0% found this document useful (0 votes)
38 views20 pages

File Handling

The document discusses file handling in C programming, explaining the concept of files as a collection of bytes stored on a disk. It outlines the two types of files, text and binary, and describes how to open and manipulate files using the FILE structure in C. Additionally, it provides examples of reading from and writing to files, as well as handling data structures for storing related information.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
38 views20 pages

File Handling

The document discusses file handling in C programming, explaining the concept of files as a collection of bytes stored on a disk. It outlines the two types of files, text and binary, and describes how to open and manipulate files using the FILE structure in C. Additionally, it provides examples of reading from and writing to files, as well as handling data structures for storing related information.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 20
1 CHAPTER: J File Handling in CG a: fe. | A file is thought a0 -0f as a system of bytes of L characters stored conti piously in _memony: |_A file ts ‘a place on the dick whers paoup of telated data is =|nnen we request the operating system to open a fle. then ei backs pointa, te stwuctine FILE we: - siemens =| tac fle hes He ono FILE stove cmrekdpi abou tna fle herp! vseay/aelirte clment eS eicee tonto memory. ate tune that contess ‘Scanned with CamScanner _of file lased The clesiny pescasted with file have data file met be that all informatven ensures +H ivetete Cte b> H include < copie. b> Bt iodude ( stettib-h void _macn () i FILE 4p e [7 be= gopen ("my file tat”, "e's ig (4ip== nit) ‘Scanned with CamScanner FILE Xp 5 spon yfle-bet [Mesg" eee See (append & read) fi include (stellib-h> void main () = ‘Scanned with CamScanner Cpermg @ Fle Te performs three fr? mode _oe open important tasks hen Searcher disk the fle ds_ the 46le from dé a werner. Called butfon ath bss i B_choxacten pointer that pornie to first == =|The_chanacten io _bugter, sould be caattien to file disk, ae Be buf would be elfminated foom memory Keypoard| _[pegeam| [piel [Paegram] [Monto | I | | | formaiied data | carb () | ¢peter bO [eet [panel getO Pine tet | pusc | getch () em Sputel) | fyetoC) | putehO _| Putehas ¢) 2 $reade) eee a ‘Scanned with CamScanner —— tate esi at ED Se Ae re ‘Scanned with CamScanner, ety chayacters Ge ae R diplay fe matey __ Hf include ee tie void mar(_) _gobie Reniper onyelame ta if ($ps= nue) __patntg (" File covteln 4 gh seek betcn( oe exit (0) 5 ‘Scanned with CamScanner See ___puint f ("Ble coudnd be opened"): a - eee exit (0) 5 printy ("Enter some characters") while ((ch= getchan ¢))!= to!) i z “pute (chide); Pout g Cibo characters. from fle ae ahtle (Gh paete (pp) |= Ene ) £ ae a ‘Scanned with CamScanner Q create @ stauctuse called stadent ‘harms mame 3 “record 3 Store Te in pile called aaa bioplay infor maton: FP inuude (stdib-h> SS aint lapel __int _soline 4 Void maroc) Shel cident cs Ba 82 ote (Teederd a” “ if_Gp==nue) ane a — friend paint ("Fle couldn't te opened) 5 “_getch s exit (0)5 ‘Scanned with CamScanner_ A Structure called student having name,age @ letino. Input n recorde ,store tthem tafe called [* student ext" & deploy ingewmodipg se ss | Stace} Student a Li — penis at tonbete. doi ———— ‘ chaz name [20] 5 int ape 3 int _vellno s + Bis cei ‘Scanned with CamScanner a scan} : | print} (Enter. solino.") 5 seang ("*d", & SU. tollno) 5 toate (Ks, sizeof (5), 1, 4p)i remind (4p) 5 Peintf ("The information of statert is :\n"); for ff Sd Name —paadvess Suly — ombenfnth fea i foes ee Tnput 400 employes _ingoern [dat & deplay record of those employee is Poktana- To idseeo te) woe ne Sa ca = Struct daleobbirth Pe epceent sper cane! cwhoce oddreas | struct employee £ igi Sc (ag ie oa ee char name [20] * chan qddress [20)is eerie at hd ee cea ‘Scanned with CamScanner pEeLEC" Enier records off 10° empleyeco.) 5. fev _(is0stSdoo 5 4+) __ __paint_C' Enter. seang ('ied", #5[1- age )s oe gets_(€ftI-name jf patntt ("Enter addrese! Ae (et tired ‘Scanned with CamScanner fread (&€ , sizeof (e) 51, $P)5 4 (stremp (efe] -addvess_, "Port ba _Salany elidname , effTadinese ,eC'7- td, el. Bier, mm oltdedd -d8)5 ‘Scanned with CamScanner _AP= topen (" university do if Gp == NULL) | hinge painth ("Fite cout __getcho s exit (0); printf ("Enter how many col seang (“#d" &n) 5 paiotf ("Enter xd records of tee [feo i bpaint & (bps "Age= Z-dlt Gonder = Ze Sere “hb ss Se “genden, marks) 3 eg Kage & gender , Kmarks)5 dt Gender = ec It Maxks= "+f age _ ‘Scanned with CamScanner

You might also like