

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A c++ program that implements a student record management system. The program allows users to perform various operations on student records, such as packing (storing) records in a file, unpacking (retrieving) records from the file, modifying existing records, and searching for records based on the student's unique identification number (usn). The program uses a fixed-length record format to store the student's usn, name, and semester information. The program demonstrates the use of file i/o operations, string manipulation, and class-based object-oriented programming techniques to manage student records efficiently. This document could be useful for students studying data structures, file handling, and object-oriented programming concepts in c++.
Typology: Summaries
1 / 3
This page cannot be seen from the preview
Don't miss anything!


#include
cout << "\nEnter USN,Name & Sem\n"; cin >> usn >> name >> sem; } void student::pack () { int i; fstream fp; fp.open ("data.txt", ios::out | ios::app); fp << usn << "|" << name << "|" << sem << "|#"; int len = strlen (usn) + strlen (name) + strlen (sem) + 4; for (i = len; i < max; i++) fp << "$"; fp.close (); } int student::search1 (char *regno) { int j = 0; fstream fp; fp.open ("data.txt", ios::in); while (1) { j++; fp.getline (usn, 20, '|'); if (fp.fail ()) return 0; if (strcmp (usn, regno) == 0) { cout << "USN:" << usn; fp.getline (name, 20, '|'); cout << "\tName:" << name; fp.getline (sem, 10, '|'); cout << "\tSem:" << sem; fp.close (); return j; } else fp.seekg (j * max, ios::beg); } } void student::modify (char *regno) { int i; fstream fp; fp.open ("data.txt", ios::in | ios::out | ios::ate); int flag = search1 (regno); if (flag == 0) cout << "R.N.F\n"; else { fp.seekp ((flag - 1) * max, ios::beg); read (); fp << usn << "|" << name << "|" << sem << "|#"; int len = strlen (usn) + strlen (name) + strlen (sem) + 4; for (i = len; i < max; i++) fp << "$"; } fp.close ();