SlideShare uma empresa Scribd logo
1 de 13
Lecture 22Lecture 22
Version 1.0Version 1.0
More on FilesMore on Files
2Rushdi Shams, Dept of CSE, KUET, Bangladesh
A File Copy ProgramA File Copy Program
 We will take a look at how you read from a fileWe will take a look at how you read from a file
 And then how you can put the content of thatAnd then how you can put the content of that
file into another filefile into another file
3Rushdi Shams, Dept of CSE, KUET, Bangladesh
4Rushdi Shams, Dept of CSE, KUET, Bangladesh
File Opening ModesFile Opening Modes
 Read (r)Read (r)
Searches the fileSearches the file
If the search is successfulIf the search is successful
load the file into memoryload the file into memory
set a pointer at the beginning of the fileset a pointer at the beginning of the file
If the file cannot be openedIf the file cannot be opened
returns NULLreturns NULL
Only reads from fileOnly reads from file
5Rushdi Shams, Dept of CSE, KUET, Bangladesh
File Opening ModesFile Opening Modes
 Write (w)Write (w)
Searches the fileSearches the file
If the file existsIf the file exists
it is overwrittenit is overwritten
If notIf not
a new file is createda new file is created
If the file cannot be openedIf the file cannot be opened
returns NULLreturns NULL
Only writes to fileOnly writes to file
6Rushdi Shams, Dept of CSE, KUET, Bangladesh
File Opening ModesFile Opening Modes
 Append (a)Append (a)
Searches the fileSearches the file
If the search is successfulIf the search is successful
load the file into memoryload the file into memory
set a pointer at the end of the fileset a pointer at the end of the file
If the file cannot be openedIf the file cannot be opened
returns NULLreturns NULL
Adding new contents in the fileAdding new contents in the file
7Rushdi Shams, Dept of CSE, KUET, Bangladesh
File Opening ModesFile Opening Modes
 Append Plus (a+)Append Plus (a+)
Searches the fileSearches the file
If the search is successfulIf the search is successful
load the file into memoryload the file into memory
If not foundIf not found
create a new filecreate a new file
If the file cannot be openedIf the file cannot be opened
returns NULLreturns NULL
Reading, appending in fileReading, appending in file
Cannot modifyCannot modify
8Rushdi Shams, Dept of CSE, KUET, Bangladesh
File Opening ModesFile Opening Modes
 Read Plus (r+)Read Plus (r+)
Searches the fileSearches the file
If the search is successfulIf the search is successful
load the file into memoryload the file into memory
set a pointer at first characterset a pointer at first character
If the file cannot be openedIf the file cannot be opened
returns NULLreturns NULL
Reading, writing, modifying contents in the fileReading, writing, modifying contents in the file
9Rushdi Shams, Dept of CSE, KUET, Bangladesh
File Opening ModesFile Opening Modes
 Write Plus (w+)Write Plus (w+)
Searches the fileSearches the file
If the file existsIf the file exists
it is overwrittenit is overwritten
If notIf not
a new file is createda new file is created
If the file cannot be openedIf the file cannot be opened
returns NULLreturns NULL
Writing, reading and modifying contentsWriting, reading and modifying contents
10Rushdi Shams, Dept of CSE, KUET, Bangladesh
String in FilesString in Files
 So far we have seen how to manipulateSo far we have seen how to manipulate
characters in filescharacters in files
 Now, we will see that handling strings in files isNow, we will see that handling strings in files is
as easy as handling charactersas easy as handling characters
 At first we will see how to write strings into aAt first we will see how to write strings into a
filefile
11Rushdi Shams, Dept of CSE, KUET, Bangladesh
12Rushdi Shams, Dept of CSE, KUET, Bangladesh
 Now we will see how to read strings from filesNow we will see how to read strings from files
13Rushdi Shams, Dept of CSE, KUET, Bangladesh

Mais conteúdo relacionado

Semelhante a File Copy Program Lecture - Read, Write Strings Files

File handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reuge
File handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reugeFile handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reuge
File handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reugevsol7206
 
Python files / directories part15
Python files / directories  part15Python files / directories  part15
Python files / directories part15Vishal Dutt
 
File handling4.pdf
File handling4.pdfFile handling4.pdf
File handling4.pdfsulekha24
 
Python Files I_O17.pdf
Python Files I_O17.pdfPython Files I_O17.pdf
Python Files I_O17.pdfRashmiAngane1
 
File Handling Python
File Handling PythonFile Handling Python
File Handling PythonAkhil Kaushik
 
File handing in C
File handing in CFile handing in C
File handing in Cshrishcg
 
File handling and Dictionaries in python
File handling and Dictionaries in pythonFile handling and Dictionaries in python
File handling and Dictionaries in pythonnitamhaske
 
what are python basics.pptx.Join Python training in Chandigarh
what are python basics.pptx.Join Python training in Chandigarhwhat are python basics.pptx.Join Python training in Chandigarh
what are python basics.pptx.Join Python training in Chandigarhasmeerana605
 
File handling in C hhsjsjshsjjsjsjs.pptx
File handling in C hhsjsjshsjjsjsjs.pptxFile handling in C hhsjsjshsjjsjsjs.pptx
File handling in C hhsjsjshsjjsjsjs.pptxarmaansohail9356
 

Semelhante a File Copy Program Lecture - Read, Write Strings Files (20)

File handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reuge
File handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reugeFile handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reuge
File handling3 (1).pdf uhgipughserigrfiogrehpiuhnfi;reuge
 
pspp-rsk.pptx
pspp-rsk.pptxpspp-rsk.pptx
pspp-rsk.pptx
 
Unit-VI.pptx
Unit-VI.pptxUnit-VI.pptx
Unit-VI.pptx
 
Filesin c++
Filesin c++Filesin c++
Filesin c++
 
Python files / directories part15
Python files / directories  part15Python files / directories  part15
Python files / directories part15
 
File handling4.pdf
File handling4.pdfFile handling4.pdf
File handling4.pdf
 
FILES IN C
FILES IN CFILES IN C
FILES IN C
 
Python Files I_O17.pdf
Python Files I_O17.pdfPython Files I_O17.pdf
Python Files I_O17.pdf
 
File Handling Python
File Handling PythonFile Handling Python
File Handling Python
 
File Handling in C
File Handling in CFile Handling in C
File Handling in C
 
File accessing modes in c
File accessing modes in cFile accessing modes in c
File accessing modes in c
 
File handling3.pdf
File handling3.pdfFile handling3.pdf
File handling3.pdf
 
File handling in c
File handling in cFile handling in c
File handling in c
 
File handling
File handlingFile handling
File handling
 
File handing in C
File handing in CFile handing in C
File handing in C
 
File handling and Dictionaries in python
File handling and Dictionaries in pythonFile handling and Dictionaries in python
File handling and Dictionaries in python
 
what are python basics.pptx.Join Python training in Chandigarh
what are python basics.pptx.Join Python training in Chandigarhwhat are python basics.pptx.Join Python training in Chandigarh
what are python basics.pptx.Join Python training in Chandigarh
 
Python-FileHandling.pptx
Python-FileHandling.pptxPython-FileHandling.pptx
Python-FileHandling.pptx
 
Com ed 5 final
Com ed 5 finalCom ed 5 final
Com ed 5 final
 
File handling in C hhsjsjshsjjsjsjs.pptx
File handling in C hhsjsjshsjjsjsjs.pptxFile handling in C hhsjsjshsjjsjsjs.pptx
File handling in C hhsjsjshsjjsjsjs.pptx
 

Mais de Rushdi Shams

Research Methodology and Tips on Better Research
Research Methodology and Tips on Better ResearchResearch Methodology and Tips on Better Research
Research Methodology and Tips on Better ResearchRushdi Shams
 
Common evaluation measures in NLP and IR
Common evaluation measures in NLP and IRCommon evaluation measures in NLP and IR
Common evaluation measures in NLP and IRRushdi Shams
 
Machine learning with nlp 101
Machine learning with nlp 101Machine learning with nlp 101
Machine learning with nlp 101Rushdi Shams
 
Semi-supervised classification for natural language processing
Semi-supervised classification for natural language processingSemi-supervised classification for natural language processing
Semi-supervised classification for natural language processingRushdi Shams
 
Natural Language Processing: Parsing
Natural Language Processing: ParsingNatural Language Processing: Parsing
Natural Language Processing: ParsingRushdi Shams
 
Types of machine translation
Types of machine translationTypes of machine translation
Types of machine translationRushdi Shams
 
L1 l2 l3 introduction to machine translation
L1 l2 l3  introduction to machine translationL1 l2 l3  introduction to machine translation
L1 l2 l3 introduction to machine translationRushdi Shams
 
Syntax and semantics
Syntax and semanticsSyntax and semantics
Syntax and semanticsRushdi Shams
 
Propositional logic
Propositional logicPropositional logic
Propositional logicRushdi Shams
 
Probabilistic logic
Probabilistic logicProbabilistic logic
Probabilistic logicRushdi Shams
 
Knowledge structure
Knowledge structureKnowledge structure
Knowledge structureRushdi Shams
 
Knowledge representation
Knowledge representationKnowledge representation
Knowledge representationRushdi Shams
 
L5 understanding hacking
L5  understanding hackingL5  understanding hacking
L5 understanding hackingRushdi Shams
 
L2 Intrusion Detection System (IDS)
L2  Intrusion Detection System (IDS)L2  Intrusion Detection System (IDS)
L2 Intrusion Detection System (IDS)Rushdi Shams
 

Mais de Rushdi Shams (20)

Research Methodology and Tips on Better Research
Research Methodology and Tips on Better ResearchResearch Methodology and Tips on Better Research
Research Methodology and Tips on Better Research
 
Common evaluation measures in NLP and IR
Common evaluation measures in NLP and IRCommon evaluation measures in NLP and IR
Common evaluation measures in NLP and IR
 
Machine learning with nlp 101
Machine learning with nlp 101Machine learning with nlp 101
Machine learning with nlp 101
 
Semi-supervised classification for natural language processing
Semi-supervised classification for natural language processingSemi-supervised classification for natural language processing
Semi-supervised classification for natural language processing
 
Natural Language Processing: Parsing
Natural Language Processing: ParsingNatural Language Processing: Parsing
Natural Language Processing: Parsing
 
Types of machine translation
Types of machine translationTypes of machine translation
Types of machine translation
 
L1 l2 l3 introduction to machine translation
L1 l2 l3  introduction to machine translationL1 l2 l3  introduction to machine translation
L1 l2 l3 introduction to machine translation
 
Syntax and semantics
Syntax and semanticsSyntax and semantics
Syntax and semantics
 
Propositional logic
Propositional logicPropositional logic
Propositional logic
 
Probabilistic logic
Probabilistic logicProbabilistic logic
Probabilistic logic
 
L15 fuzzy logic
L15  fuzzy logicL15  fuzzy logic
L15 fuzzy logic
 
Knowledge structure
Knowledge structureKnowledge structure
Knowledge structure
 
Knowledge representation
Knowledge representationKnowledge representation
Knowledge representation
 
First order logic
First order logicFirst order logic
First order logic
 
Belief function
Belief functionBelief function
Belief function
 
L5 understanding hacking
L5  understanding hackingL5  understanding hacking
L5 understanding hacking
 
L4 vpn
L4  vpnL4  vpn
L4 vpn
 
L3 defense
L3  defenseL3  defense
L3 defense
 
L2 Intrusion Detection System (IDS)
L2  Intrusion Detection System (IDS)L2  Intrusion Detection System (IDS)
L2 Intrusion Detection System (IDS)
 
L1 phishing
L1  phishingL1  phishing
L1 phishing
 

Último

Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 

Último (20)

Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 

File Copy Program Lecture - Read, Write Strings Files

  • 1. Lecture 22Lecture 22 Version 1.0Version 1.0 More on FilesMore on Files
  • 2. 2Rushdi Shams, Dept of CSE, KUET, Bangladesh A File Copy ProgramA File Copy Program  We will take a look at how you read from a fileWe will take a look at how you read from a file  And then how you can put the content of thatAnd then how you can put the content of that file into another filefile into another file
  • 3. 3Rushdi Shams, Dept of CSE, KUET, Bangladesh
  • 4. 4Rushdi Shams, Dept of CSE, KUET, Bangladesh File Opening ModesFile Opening Modes  Read (r)Read (r) Searches the fileSearches the file If the search is successfulIf the search is successful load the file into memoryload the file into memory set a pointer at the beginning of the fileset a pointer at the beginning of the file If the file cannot be openedIf the file cannot be opened returns NULLreturns NULL Only reads from fileOnly reads from file
  • 5. 5Rushdi Shams, Dept of CSE, KUET, Bangladesh File Opening ModesFile Opening Modes  Write (w)Write (w) Searches the fileSearches the file If the file existsIf the file exists it is overwrittenit is overwritten If notIf not a new file is createda new file is created If the file cannot be openedIf the file cannot be opened returns NULLreturns NULL Only writes to fileOnly writes to file
  • 6. 6Rushdi Shams, Dept of CSE, KUET, Bangladesh File Opening ModesFile Opening Modes  Append (a)Append (a) Searches the fileSearches the file If the search is successfulIf the search is successful load the file into memoryload the file into memory set a pointer at the end of the fileset a pointer at the end of the file If the file cannot be openedIf the file cannot be opened returns NULLreturns NULL Adding new contents in the fileAdding new contents in the file
  • 7. 7Rushdi Shams, Dept of CSE, KUET, Bangladesh File Opening ModesFile Opening Modes  Append Plus (a+)Append Plus (a+) Searches the fileSearches the file If the search is successfulIf the search is successful load the file into memoryload the file into memory If not foundIf not found create a new filecreate a new file If the file cannot be openedIf the file cannot be opened returns NULLreturns NULL Reading, appending in fileReading, appending in file Cannot modifyCannot modify
  • 8. 8Rushdi Shams, Dept of CSE, KUET, Bangladesh File Opening ModesFile Opening Modes  Read Plus (r+)Read Plus (r+) Searches the fileSearches the file If the search is successfulIf the search is successful load the file into memoryload the file into memory set a pointer at first characterset a pointer at first character If the file cannot be openedIf the file cannot be opened returns NULLreturns NULL Reading, writing, modifying contents in the fileReading, writing, modifying contents in the file
  • 9. 9Rushdi Shams, Dept of CSE, KUET, Bangladesh File Opening ModesFile Opening Modes  Write Plus (w+)Write Plus (w+) Searches the fileSearches the file If the file existsIf the file exists it is overwrittenit is overwritten If notIf not a new file is createda new file is created If the file cannot be openedIf the file cannot be opened returns NULLreturns NULL Writing, reading and modifying contentsWriting, reading and modifying contents
  • 10. 10Rushdi Shams, Dept of CSE, KUET, Bangladesh String in FilesString in Files  So far we have seen how to manipulateSo far we have seen how to manipulate characters in filescharacters in files  Now, we will see that handling strings in files isNow, we will see that handling strings in files is as easy as handling charactersas easy as handling characters  At first we will see how to write strings into aAt first we will see how to write strings into a filefile
  • 11. 11Rushdi Shams, Dept of CSE, KUET, Bangladesh
  • 12. 12Rushdi Shams, Dept of CSE, KUET, Bangladesh  Now we will see how to read strings from filesNow we will see how to read strings from files
  • 13. 13Rushdi Shams, Dept of CSE, KUET, Bangladesh