Student Record Management System, Summaries of Stereochemistry

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

2022/2023

Uploaded on 07/07/2023

raghavendra-s-nayak
raghavendra-s-nayak 🇮🇳

2 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
#include<iostream>
#include<fstream>
#include<string.h>
#include<stdlib.h>
#define max 50
using namespace std;
class student
{
char usn[20];
char name[20];
char sem[10];
public:
void read();
void pack();
void unpack();
void modify(char *);
int search1(char *);
} s;
int main ()
{
int ch;
char regno[20];
cout<<"\nFIXED LENGTH RECORDS";
cout<<"\nSIZE OF EACH REC = "<<max;
while (1)
{
cout << "\n1:Pack 2:Unpack 3:Modify 4:Search 5:Exit\n";
cin >> ch;
switch (ch)
{
case 1: s.read ();
s.pack ();
break;
case 2: s.unpack ();
break;
case 3: cout << "Enter USN\n";
cin >> regno;
s.modify (regno);
break;
case 4: cout << "Enter USN to search\n";
cin >> regno;
int f;
f = s.search1 (regno);
if (f == 0)
cout << "Not found\n";
else
cout << "\nFound @" << f <<
"position";
break;
case 5: exit (0);
break;
}
}
}
void student::read ()
{
pf3

Partial preview of the text

Download Student Record Management System and more Summaries Stereochemistry in PDF only on Docsity!

#include #include #include<string.h> #include<stdlib.h> #define max 50 using namespace std; class student { char usn[20]; char name[20]; char sem[10]; public: void read(); void pack(); void unpack(); void modify(char *); int search1(char *); } s; int main () { int ch; char regno[20]; cout<<"\nFIXED LENGTH RECORDS"; cout<<"\nSIZE OF EACH REC = "<<max; while (1) { cout << "\n1:Pack 2:Unpack 3:Modify 4:Search 5:Exit\n"; cin >> ch; switch (ch) { case 1: s.read (); s.pack (); break; case 2: s.unpack (); break; case 3: cout << "Enter USN\n"; cin >> regno; s.modify (regno); break; case 4: cout << "Enter USN to search\n"; cin >> regno; int f; f = s.search1 (regno); if (f == 0) cout << "Not found\n"; else cout << "\nFound @" << f << "position"; break; case 5: exit (0); break; } } } void student::read () {

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 ();