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

Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Dust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEDust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEaurabinda banchhor
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxruthvilladarez
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Millenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxMillenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxJanEmmanBrigoli
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operationalssuser3e220a
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 

Último (20)

Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Dust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEDust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSE
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docx
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Millenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxMillenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptx
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operational
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.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