0% found this document useful (0 votes)
14 views4 pages

BSE183085 Assignment

Uploaded by

Talha Khan Music
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views4 pages

BSE183085 Assignment

Uploaded by

Talha Khan Music
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

NAME:Talha Ulfat Lodhi

REG NO.BSE183085

Code:

#include <iostream>

#include<fstream>

#include <string>

using namespace std;

class student {

string name;

int mark;

public:

student() {

name = "null";

mark = 0;

string getname() {

return name;

void setname(string n) {

name = n;

int getmark() {

return mark;

void setmark(int m) {

mark = m;
}

void display() {

cout << name << " " << mark << endl;

void write(ofstream& out) {

out << name << " " << mark << endl;

void read(ifstream& in) {

in >> name >> mark;

};

int sizeoffile() {

ifstream in;

in.open("student.txt");

int s = 0;

string m;

getline(in, m);

while (!(in.eof())) {

s++;

getline(in, m);

in.close();

return s;

int main()

int nos = sizeoffile();

cout << nos;


student *s;

s = new student[nos];

ifstream in;

in.open("student.txt");

if (in.is_open()) {

for (int i = 0; i < 3; i++) {

s[i].read(in);

s[i].display();

in.close();

else {

cout << "not exist";

ofstream out;

out.open("student.txt", ios::app);

if (out.is_open())

for (int i = 0; i < 3; i++) {

string n;

int m;

cin >> n >> m;

s[i].setname(n);

s[i].setmark(m);

s[i].write(out);

}
}

else{

cout << "file not open";

out.close();

You might also like