SlideShare a Scribd company logo
1 of 22
Download to read offline
Prog_2 course- 2014 
2 bytes team 
Kinan keshkeh 
IT Engineering-Damascus University 
3rd year
Files 
TxT Files 
char(ACII) 
Binary File 
0/1
Who can tell me from where we read and write in our normal program? 
In Files: Keyboard file Screen file 
Why files? To save things..(whereas in normal way we cant save things after program end).. Then we can read|| write from it ! 
NOTE: First of all.. We have to know that each file has Pointer at the Begin of file and Pointer at the End of it -The end of line determined by (Enter) #13
There is : 
Physical name ( koko.txt /koko.bin) 
logical name (f:txt / f:file of _sth_) 
File : 
read 
write 
Note: Attention !! The most important thing is the method we read and write files 
modification 
has its arrangement(use another file to help )
TXT FILES
The Definition 
At main Program: 
Var f :Text; 
At procedures/functions: 
procedure ___(…Var f :txt) 
We use “Assign” to link physical name with logical name: Assign(f,<filename>) 
-If the file at (Bin)(the same folder of pascal) : you don‟t have to write whole direction Ex:(Assign(f,‟soso.txt‟) ) -else you have to write whole direction Ex:(Assign(f ,‟D:fififofo….soso.txt‟) )
The Definition 
At main Program: 
Var f :TXT; 
At procedures/functions: 
procedure ___(…Var f :txt) 
We use “Assign” to link physical name with logical name: Assign(f,<filename>) 
-If the file at (Bin)(the same folder of pascal) : you don‟t have to write whole direction Ex:(Assign(f,‟soso.txt‟) ) -else you have to write whole direction Ex:(Assign(f ,‟D:fififofo….soso.txt‟) )
Read from Txtfile 
Reset(f) 
Read(f,c); (when you dunno how the file is created ) 
Readln(f,st); 
Readln(f); 
+1 
close(f)
write from Txtfile 
Rewrite(f) 
write(f,c); 
writeln(f,st); 
writeln(f); 
+1 
close(f)
Notes On Reset/Rewrite: 
If File exist 
If File Not exist 
Reset 
Put the Pointer at the begin of file .. 
Error 
Rewrite 
Erase file content 
And put the Pointer at the begin of file to write 
Create new file
How can we know the end of file ?? How can we do the end of line ? 
Eof(f): return true when the file end. 
Eoln (f): return true when the line end.
Lets make it real :D !!
-------- 
EMPno EMPName SAL 
100 saeed 5000 
2 Eyad 25000 
78 
-------- 
------------ 
. 
. 
. 
. 
. 
Ques: We want to write a Txt file like that below ..and read from it and print its content on Screen :
Write on file: 
Program Soso; 
Var filename:string[20]; 
f:txt; i:integer; c:char; st:string[100]; 
Eno:integer; Ename:string[40]; Esal:real; 
Begin 
readln(filename); Assign(f, filename); 
Rewrite(f); 
writeln(f, „EMPno‟:15,‟EMPName‟:15,‟ SAL‟:20); 
writeln(f,‟----------‟,‟ -----------------‟,‟-----------‟); 
for i:=1 to 100 do 
begin 
readln(Eno,Ename,Esal); 
writeln(f,Eno,Ename,Esal); 
end; 
close(f); 
End.
Read form file 
1) (because)/if we know the structure /how it is written : 
Reset(f); 
Readln(f,st); Readln(f,st); 
While not eof(f) do 
Begin 
readln(f, Eno,Ename,Esal); 
writeln(Eno,Ename,Esal); 
end; 
Close(f); 
+1
2) (because)/if we don’t know the structure /how it is written : 
Reset(f); 
While not eof(f) do 
Begin 
while not eoln(f) do 
begin 
read(f, c); 
write(c); 
end; 
writeln; readln(f); 
end; 
Close(f); 
Reset(f); 
While not eof(f) do 
Begin 
while not eoln(f) do 
begin 
readln(f, st); 
writeln(st); 
end; 
end; 
Close(f); 
Line long 
You have to define the big number string
Important Example 
PC Computer 
We have Txtfile In English( of course :p ) 
-Each word ends at its line. 
-Between words there is Only one Space „ ‟. 
There are in this file words “Computer” .. We want replace them by ”PC”.. 
You have to Keep your eyes with me all..
Program ComputerToPC; 
VAR 
f, new: text; 
ch: Char; 
s: string[8]; 
i: integer; 
flag: boolean; 
Begin 
assign(f,'mo.txt'); 
reset(f); 
assign(new,'new.txt'); 
rewrite(new);
while not eof(f) do 
begin 
flag := true; 
while not eoln(f) do 
begin 
if flag then 
read(f, s) 
else 
begin 
read(f, ch); 
s[8] := ch; 
end; 
if s = 'computer' then 
begin 
write(new, 'PC'); 
flag := true; 
end 
else 
begin 
flag := false; 
if eoln(f) then 
write(new, s) 
else 
write(new, s[1]); 
for i := 1 to 7 do 
s[i] := s[i+1]; 
end; 
end; 
readln(f); 
writeln(new); 
end; 
close(new); 
readln; 
End.{program}
When we want to open an existing text file for writing at the end of it , without removing its original contents using the procedure Append 
Appending to a text file: 
Program Soso; 
Var filename:string[20]; 
f:txt; st:string[10]; 
Begin 
readln(filename); Assign(f, filename); 
Append(f); 
writeln(„put what do you want at the End of file : ‟); 
readln(st); 
writeln(f,st); 
close(f); 
End.
Homework: you have a TXTfile it contains Student name/student number/prog_1 mark/prog_2 mark/ 1)put the sum of the two subjects to this file , then ensure of that. 2)print the sum of the two subjects on screen 
+10 points 
+7 
+3
Group : group link 
Mobile phone- Kinan : 0994385748 
Facebook account : kinan’s account 
2 bytes team

More Related Content

What's hot

File Management in C
File Management in CFile Management in C
File Management in CPaurav Shah
 
File handling in 'C'
File handling in 'C'File handling in 'C'
File handling in 'C'Gaurav Garg
 
File handling in c
File handling in c File handling in c
File handling in c Vikash Dhal
 
file handling1
file handling1file handling1
file handling1student
 
Linux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for BeginnersLinux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for BeginnersDavide Ciambelli
 
File handling-dutt
File handling-duttFile handling-dutt
File handling-duttAnil Dutt
 
Python - File operations & Data parsing
Python - File operations & Data parsingPython - File operations & Data parsing
Python - File operations & Data parsingFelix Z. Hoffmann
 
[PDF] 2021 Termux basic commands list
[PDF] 2021 Termux basic commands list [PDF] 2021 Termux basic commands list
[PDF] 2021 Termux basic commands list nisivaasdfghj
 
Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014Noé Fernández-Pozo
 
Python 3.x File Object Manipulation Cheatsheet
Python 3.x File Object Manipulation CheatsheetPython 3.x File Object Manipulation Cheatsheet
Python 3.x File Object Manipulation CheatsheetIsham Rashik
 
Concept of file handling in c
Concept of file handling in cConcept of file handling in c
Concept of file handling in cMugdhaSharma11
 
Chapter 13.1.10
Chapter 13.1.10Chapter 13.1.10
Chapter 13.1.10patcha535
 
Files and Directories in PHP
Files and Directories in PHPFiles and Directories in PHP
Files and Directories in PHPNicole Ryan
 

What's hot (19)

File Management in C
File Management in CFile Management in C
File Management in C
 
Module 5 file cp
Module 5 file cpModule 5 file cp
Module 5 file cp
 
File handling in 'C'
File handling in 'C'File handling in 'C'
File handling in 'C'
 
File handling in c
File handling in c File handling in c
File handling in c
 
file handling1
file handling1file handling1
file handling1
 
File handling in c
File  handling in cFile  handling in c
File handling in c
 
File Management
File ManagementFile Management
File Management
 
Linux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for BeginnersLinux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for Beginners
 
File handling-dutt
File handling-duttFile handling-dutt
File handling-dutt
 
File management
File managementFile management
File management
 
Linux cheat-sheet
Linux cheat-sheetLinux cheat-sheet
Linux cheat-sheet
 
Python - File operations & Data parsing
Python - File operations & Data parsingPython - File operations & Data parsing
Python - File operations & Data parsing
 
1file handling
1file handling1file handling
1file handling
 
[PDF] 2021 Termux basic commands list
[PDF] 2021 Termux basic commands list [PDF] 2021 Termux basic commands list
[PDF] 2021 Termux basic commands list
 
Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014
 
Python 3.x File Object Manipulation Cheatsheet
Python 3.x File Object Manipulation CheatsheetPython 3.x File Object Manipulation Cheatsheet
Python 3.x File Object Manipulation Cheatsheet
 
Concept of file handling in c
Concept of file handling in cConcept of file handling in c
Concept of file handling in c
 
Chapter 13.1.10
Chapter 13.1.10Chapter 13.1.10
Chapter 13.1.10
 
Files and Directories in PHP
Files and Directories in PHPFiles and Directories in PHP
Files and Directories in PHP
 

Viewers also liked

Moh. Hatta, "Demokrat" dalam laku dan kata
Moh. Hatta, "Demokrat" dalam laku dan kataMoh. Hatta, "Demokrat" dalam laku dan kata
Moh. Hatta, "Demokrat" dalam laku dan kataF1trah
 
Diaz castro
Diaz castroDiaz castro
Diaz castromteribg
 
Intervención psicológica off y on line en enfermedades crónicas III
 Intervención psicológica off y on line en enfermedades crónicas III Intervención psicológica off y on line en enfermedades crónicas III
Intervención psicológica off y on line en enfermedades crónicas IIIZara Casañ
 

Viewers also liked (6)

Moh. Hatta, "Demokrat" dalam laku dan kata
Moh. Hatta, "Demokrat" dalam laku dan kataMoh. Hatta, "Demokrat" dalam laku dan kata
Moh. Hatta, "Demokrat" dalam laku dan kata
 
Diaz castro
Diaz castroDiaz castro
Diaz castro
 
Intervención psicológica off y on line en enfermedades crónicas III
 Intervención psicológica off y on line en enfermedades crónicas III Intervención psicológica off y on line en enfermedades crónicas III
Intervención psicológica off y on line en enfermedades crónicas III
 
Pronouns
PronounsPronouns
Pronouns
 
Ghost
GhostGhost
Ghost
 
Cristo, el fin de la ley
Cristo, el fin de la leyCristo, el fin de la ley
Cristo, el fin de la ley
 

Similar to 2Bytesprog2 course_2014_c1_sets

Similar to 2Bytesprog2 course_2014_c1_sets (20)

File Handling in c.ppt
File Handling in c.pptFile Handling in c.ppt
File Handling in c.ppt
 
File handling-c
File handling-cFile handling-c
File handling-c
 
file_handling_in_c.ppt
file_handling_in_c.pptfile_handling_in_c.ppt
file_handling_in_c.ppt
 
Advance C Programming UNIT 4-FILE HANDLING IN C.pdf
Advance C Programming UNIT 4-FILE HANDLING IN C.pdfAdvance C Programming UNIT 4-FILE HANDLING IN C.pdf
Advance C Programming UNIT 4-FILE HANDLING IN C.pdf
 
Unit5 C
Unit5 C Unit5 C
Unit5 C
 
PPS PPT 2.pptx
PPS PPT 2.pptxPPS PPT 2.pptx
PPS PPT 2.pptx
 
Satz1
Satz1Satz1
Satz1
 
Unit5
Unit5Unit5
Unit5
 
4 text file
4 text file4 text file
4 text file
 
FILE HANDLING.pptx
FILE HANDLING.pptxFILE HANDLING.pptx
FILE HANDLING.pptx
 
Lecture 20 - File Handling
Lecture 20 - File HandlingLecture 20 - File Handling
Lecture 20 - File Handling
 
Programming in C
Programming in CProgramming in C
Programming in C
 
Programming in C
Programming in CProgramming in C
Programming in C
 
Unit-VI.pptx
Unit-VI.pptxUnit-VI.pptx
Unit-VI.pptx
 
EASY UNDERSTANDING OF FILES IN C LANGUAGE.pdf
EASY UNDERSTANDING OF FILES IN C LANGUAGE.pdfEASY UNDERSTANDING OF FILES IN C LANGUAGE.pdf
EASY UNDERSTANDING OF FILES IN C LANGUAGE.pdf
 
Files_in_C.ppt
Files_in_C.pptFiles_in_C.ppt
Files_in_C.ppt
 
C Programming Unit-5
C Programming Unit-5C Programming Unit-5
C Programming Unit-5
 
ppt5-190810161800 (1).pdf
ppt5-190810161800 (1).pdfppt5-190810161800 (1).pdf
ppt5-190810161800 (1).pdf
 
Python programming : Files
Python programming : FilesPython programming : Files
Python programming : Files
 
FILES IN C
FILES IN CFILES IN C
FILES IN C
 

More from kinan keshkeh

10 Little Tricks to Get Your Class’s Attention (and Hold It)
10 Little Tricks to Get Your  Class’s Attention (and Hold It)10 Little Tricks to Get Your  Class’s Attention (and Hold It)
10 Little Tricks to Get Your Class’s Attention (and Hold It)kinan keshkeh
 
Simpson and lagranje dalambair math methods
Simpson and lagranje dalambair math methods Simpson and lagranje dalambair math methods
Simpson and lagranje dalambair math methods kinan keshkeh
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptkinan keshkeh
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptkinan keshkeh
 
GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm  GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm kinan keshkeh
 
Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...kinan keshkeh
 
2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graphkinan keshkeh
 
2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_unitskinan keshkeh
 
2Bytesprog2 course_2014_c7_double_lists
2Bytesprog2 course_2014_c7_double_lists2Bytesprog2 course_2014_c7_double_lists
2Bytesprog2 course_2014_c7_double_listskinan keshkeh
 
2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked list2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked listkinan keshkeh
 
2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointerskinan keshkeh
 
2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfiles2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfileskinan keshkeh
 
2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfiles2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfileskinan keshkeh
 
2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_records2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_recordskinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_setskinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_setskinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_setskinan keshkeh
 
2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templates2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templateskinan keshkeh
 
2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphism2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphismkinan keshkeh
 
2 BytesC++ course_2014_c11_ inheritance
2 BytesC++ course_2014_c11_ inheritance2 BytesC++ course_2014_c11_ inheritance
2 BytesC++ course_2014_c11_ inheritancekinan keshkeh
 

More from kinan keshkeh (20)

10 Little Tricks to Get Your Class’s Attention (and Hold It)
10 Little Tricks to Get Your  Class’s Attention (and Hold It)10 Little Tricks to Get Your  Class’s Attention (and Hold It)
10 Little Tricks to Get Your Class’s Attention (and Hold It)
 
Simpson and lagranje dalambair math methods
Simpson and lagranje dalambair math methods Simpson and lagranje dalambair math methods
Simpson and lagranje dalambair math methods
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop concept
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop concept
 
GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm  GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm
 
Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...
 
2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph
 
2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units
 
2Bytesprog2 course_2014_c7_double_lists
2Bytesprog2 course_2014_c7_double_lists2Bytesprog2 course_2014_c7_double_lists
2Bytesprog2 course_2014_c7_double_lists
 
2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked list2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked list
 
2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers
 
2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfiles2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfiles
 
2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfiles2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfiles
 
2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_records2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_records
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
 
2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templates2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templates
 
2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphism2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphism
 
2 BytesC++ course_2014_c11_ inheritance
2 BytesC++ course_2014_c11_ inheritance2 BytesC++ course_2014_c11_ inheritance
2 BytesC++ course_2014_c11_ inheritance
 

Recently uploaded

Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxnada99848
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 

Recently uploaded (20)

Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptx
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 

2Bytesprog2 course_2014_c1_sets

  • 1. Prog_2 course- 2014 2 bytes team Kinan keshkeh IT Engineering-Damascus University 3rd year
  • 2. Files TxT Files char(ACII) Binary File 0/1
  • 3. Who can tell me from where we read and write in our normal program? In Files: Keyboard file Screen file Why files? To save things..(whereas in normal way we cant save things after program end).. Then we can read|| write from it ! NOTE: First of all.. We have to know that each file has Pointer at the Begin of file and Pointer at the End of it -The end of line determined by (Enter) #13
  • 4. There is : Physical name ( koko.txt /koko.bin) logical name (f:txt / f:file of _sth_) File : read write Note: Attention !! The most important thing is the method we read and write files modification has its arrangement(use another file to help )
  • 6. The Definition At main Program: Var f :Text; At procedures/functions: procedure ___(…Var f :txt) We use “Assign” to link physical name with logical name: Assign(f,<filename>) -If the file at (Bin)(the same folder of pascal) : you don‟t have to write whole direction Ex:(Assign(f,‟soso.txt‟) ) -else you have to write whole direction Ex:(Assign(f ,‟D:fififofo….soso.txt‟) )
  • 7. The Definition At main Program: Var f :TXT; At procedures/functions: procedure ___(…Var f :txt) We use “Assign” to link physical name with logical name: Assign(f,<filename>) -If the file at (Bin)(the same folder of pascal) : you don‟t have to write whole direction Ex:(Assign(f,‟soso.txt‟) ) -else you have to write whole direction Ex:(Assign(f ,‟D:fififofo….soso.txt‟) )
  • 8. Read from Txtfile Reset(f) Read(f,c); (when you dunno how the file is created ) Readln(f,st); Readln(f); +1 close(f)
  • 9. write from Txtfile Rewrite(f) write(f,c); writeln(f,st); writeln(f); +1 close(f)
  • 10. Notes On Reset/Rewrite: If File exist If File Not exist Reset Put the Pointer at the begin of file .. Error Rewrite Erase file content And put the Pointer at the begin of file to write Create new file
  • 11. How can we know the end of file ?? How can we do the end of line ? Eof(f): return true when the file end. Eoln (f): return true when the line end.
  • 12. Lets make it real :D !!
  • 13. -------- EMPno EMPName SAL 100 saeed 5000 2 Eyad 25000 78 -------- ------------ . . . . . Ques: We want to write a Txt file like that below ..and read from it and print its content on Screen :
  • 14. Write on file: Program Soso; Var filename:string[20]; f:txt; i:integer; c:char; st:string[100]; Eno:integer; Ename:string[40]; Esal:real; Begin readln(filename); Assign(f, filename); Rewrite(f); writeln(f, „EMPno‟:15,‟EMPName‟:15,‟ SAL‟:20); writeln(f,‟----------‟,‟ -----------------‟,‟-----------‟); for i:=1 to 100 do begin readln(Eno,Ename,Esal); writeln(f,Eno,Ename,Esal); end; close(f); End.
  • 15. Read form file 1) (because)/if we know the structure /how it is written : Reset(f); Readln(f,st); Readln(f,st); While not eof(f) do Begin readln(f, Eno,Ename,Esal); writeln(Eno,Ename,Esal); end; Close(f); +1
  • 16. 2) (because)/if we don’t know the structure /how it is written : Reset(f); While not eof(f) do Begin while not eoln(f) do begin read(f, c); write(c); end; writeln; readln(f); end; Close(f); Reset(f); While not eof(f) do Begin while not eoln(f) do begin readln(f, st); writeln(st); end; end; Close(f); Line long You have to define the big number string
  • 17. Important Example PC Computer We have Txtfile In English( of course :p ) -Each word ends at its line. -Between words there is Only one Space „ ‟. There are in this file words “Computer” .. We want replace them by ”PC”.. You have to Keep your eyes with me all..
  • 18. Program ComputerToPC; VAR f, new: text; ch: Char; s: string[8]; i: integer; flag: boolean; Begin assign(f,'mo.txt'); reset(f); assign(new,'new.txt'); rewrite(new);
  • 19. while not eof(f) do begin flag := true; while not eoln(f) do begin if flag then read(f, s) else begin read(f, ch); s[8] := ch; end; if s = 'computer' then begin write(new, 'PC'); flag := true; end else begin flag := false; if eoln(f) then write(new, s) else write(new, s[1]); for i := 1 to 7 do s[i] := s[i+1]; end; end; readln(f); writeln(new); end; close(new); readln; End.{program}
  • 20. When we want to open an existing text file for writing at the end of it , without removing its original contents using the procedure Append Appending to a text file: Program Soso; Var filename:string[20]; f:txt; st:string[10]; Begin readln(filename); Assign(f, filename); Append(f); writeln(„put what do you want at the End of file : ‟); readln(st); writeln(f,st); close(f); End.
  • 21. Homework: you have a TXTfile it contains Student name/student number/prog_1 mark/prog_2 mark/ 1)put the sum of the two subjects to this file , then ensure of that. 2)print the sum of the two subjects on screen +10 points +7 +3
  • 22. Group : group link Mobile phone- Kinan : 0994385748 Facebook account : kinan’s account 2 bytes team