BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan Right Header

Register FAQ Community Calendar New Posts Navbar Right Corner
HOME BZU Mail Box Online Games Radio and TV Cricket All Albums
Go Back   BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan > Institute of Computing > Bachelor of Science in Telecom System > BsTS 2nd Semester


Reply
 
Thread Tools Search this Thread Rating: Thread Rating: 3 votes, 4.67 average. Display Modes
  #1  
Old 11-12-2008, 09:54 AM
T-INFECTION's Avatar
ATTIQUE ATTA

 
Join Date: May 2008
Location: MULTAN
Posts: 6
Contact Number: 0333-4671561*,0345-2870285
Program / Discipline: BSTS
Class Roll Number: BSTS-08-30
T-INFECTION is on a distinguished road
Send a message via MSN to T-INFECTION
Sunny Filling in oop c++

#include <iostream>
#include <cstring>
#include <fstream>
using namespace std;
class Student
{
private:
int rollno;
char name[30];
double marks;
public:
Student()
{
rollno = 0;
strcpy(name, "");
marks = 0;
}
void InputData()
{
cout << "Enter the rollno:";
cin >> rollno;
cin.ignore (256, '\n');
cout << "Enter the name: ";
cin.getline(name, 30);
cout << "Enter the marks: ";
cin >> marks;
}
void DisplayData()
{
cout << "Rollno: " << rollno << endl;
cout << "Name: " << name << endl;
cout << "Marks: " << marks << endl;
}
};
void CreateFile()
{

ofstream os("Student.dat",ios::out|ios::binary);
if (!os)
{
cout << "Unable to create file" << endl;
exit(1);
}
cout << "Successfully File Created" << endl;
}
void AddRecord()
{
Student s;

ofstream os("Student.dat",ios::app|ios::binary);
if (!os)
{
cout << "Unable to open file" << endl;
exit(1);
}
int n;
cout << "Enter the no of records to store:";
cin >> n;
for (int i = 0; i < n; i++)
{
cout << "Enter the student Info" << endl;
s.InputData();
os.write((char *) &s, sizeof(s));
cout << "Record Stored Successfully" << endl;
}
os.close();
} // end of Add Record
void DisplayRecord()
{
Student s;
/* Statement to read records from student file */
ifstream is("Student.dat",
ios::in|ios::binary);
if (!is)
{
cout << " Unable to open file or File not found" << endl;
exit(1);
}
while (!is.eof())
{
is.read((char*) &s, sizeof(s));
if (!is.eof())
s.DisplayData();
}
is.close();
} // end of Dislay Record
int main()
{
int opt;
while (1)
{
cout << "!!!!!!!Student Database System!!!!!!!" << endl;
cout << "1: Create Student File " << endl;
cout << "2: Add Records " << endl;
cout << "3: Display Records " << endl;
cout << "4: Exit " << endl;
cout << "Ente the option: ";
cin >>opt;
if (opt == 1)
CreateFile();
else if (opt == 2)
AddRecord();
else if (opt == 3)
DisplayRecord();
else if (opt == 4)
break;
else
cout << "Invalid option" << endl;
} // end of while loop

return 0;
}
//M.ATTIQUE ATTA
//333-4671561




Reply With Quote
  #2  
Old 19-11-2010, 01:57 AM
bonfire's Avatar
M.Arsalan Qureshi

 
Join Date: Oct 2008
Location: Garden Town, Multan Cantt
Posts: 616
Program / Discipline: BSTS
Class Roll Number: 09-31
bonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond repute
Default Re: Filling in oop c++

Thanks
Reply With Quote
Reply

Tags
filling, oop


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Abh daanton ki filling ke liye drilling ki zarorat nahi .BZU. Health and Nutrition 1 21-01-2017 12:57 PM

Best view in Firefox
Almuslimeen.info | BZU Multan | Dedicated server hosting
Note: All trademarks and copyrights held by respective owners. We will take action against any copyright violation if it is proved to us.

All times are GMT +5. The time now is 01:07 PM.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.