Write a program to work with a binary (pickled) file, having functions to
5
(i) Create a binary file message.dat that stores some text having multiple lines (3 or
more lines). Store text of your choice, having at least 3 lines in it.
(ii) Open the created binary file and display all the text until letter 'h' is obtained, i.e.,
display all the text before letter 'h'.
Answers
Answered by
0
Answer:
Step 1: Searching for the word in the binary file.
Step 2: While searching in the file, the variable “pos” stores the position of file pointer record then traverse(continue) reading of the record.
Step 3: If the word to be searched exists then place the write pointer (to ending of the previous record) i.e. at pos.
Step 4: Call write() function to take the new record.
Step 5: Write the new object at the position “pos” and hence the record is updated and print “record successfully updated”.
Step 6: If the word does not exists then print “record not found”.
Implementation
Let’s suppose the content of the binary file is:
Similar questions
Social Sciences,
1 month ago
Computer Science,
1 month ago
English,
2 months ago
Math,
2 months ago
Math,
9 months ago