This post was published long ago, when I was a student and an amateur blogger. The links might be broken and content may not be useful anymore. Please read this content keeping its age in mind.
FILE STRUCTURES LAB
Semester : 6
Subject Code : O6ISL67
Experiment No. : 2
Objective of the Experiment : To make objects persistet by writing them to file . To maintain identity of fields and records , add delimiters to fields and make records of fixed length.
Build two separate classes Student and FixedLengthBuffer (Record size =75). Write overloaded insertion and extraction operators for reading and displaying student data . Implement Pack() , UnPack() ,Read(), Write () methods for performing Buffer and file opeartions.Use ‘ | ‘ as field Delimiter.
Class should have constructor to initialize buffer and student objects.
Procedure in main :
1. Create Student object and initialize
2. Create buffer object and initialize
3. Open file in write mode
4. Read data for student
5. Pack the student object into buffer
6. Write the buffer to file
7. Repeat step 4-6 for 15 students
8. Close the file.
9. Open the file in read mode
10. Read a record into buffer
11. Unpack the fields and restore the state of an Object
12. Display student record
13. Repeat steps 10-12 for all the records stored in the file
14. Close the file.
Buffer Contents Record USN Name Address Semester
11 | student1 |Belgaum |1……………. 1 11 student1 Belgaum 1
12 |student2 |bangalore |2…………… 2 12 student2 bangalore 2
superhit1000 says
how do we excute the second part in fs lab first program .. please tell in detail if any one has executed
sandeephegde says
What did you mean by “Second part in first program” ?
superhit1000 says
how do we excute the second part in fs lab first program .. please tell in detail if any one has executed
sandeephegde says
What did you mean by “Second part in first program” ?
superhit1000 says
how do we excute the second part in fs lab first program .. please tell in detail if any one has executed
sandeephegde says
What did you mean by “Second part in first program” ?
superhit1000 says
how do we get this output
USING file I/o
1 for standard I/O
2 for file I/O
Enter your choice :2
Enter data file name : name .txt
enter reverse data file name : rev.txt
[root@localhost] # catnames.txt
KLS
GOGTEtput
Science
….
how we get this out put as we know that fro local host we need to execute on fedora and its not possible to get output on Fedora. and we are using Turbo C++ complier which doesnt support this kind of output .
what should we do?
hope to hear from you soon.
superhit1000 says
how do we get this output
USING file I/o
1 for standard I/O
2 for file I/O
Enter your choice :2
Enter data file name : name .txt
enter reverse data file name : rev.txt
[root@localhost] # catnames.txt
KLS
GOGTEtput
Science
….
how we get this out put as we know that fro local host we need to execute on fedora and its not possible to get output on Fedora. and we are using Turbo C++ complier which doesnt support this kind of output .
what should we do?
hope to hear from you soon.
superhit1000 says
how do we get this output
USING file I/o
1 for standard I/O
2 for file I/O
Enter your choice :2
Enter data file name : name .txt
enter reverse data file name : rev.txt
[root@localhost] # catnames.txt
KLS
GOGTEtput
Science
….
how we get this out put as we know that fro local host we need to execute on fedora and its not possible to get output on Fedora. and we are using Turbo C++ complier which doesnt support this kind of output .
what should we do?
hope to hear from you soon.
RAVi says
Ya.. U have kept these uniquely