Question: Answer back in next 20mints Observe the given below program segment carefully and perform two tasks: i. Fill the blanks marked using seekg(), seekp(), tellp()

Answer back in next 20mints

Observe the given below program segment carefully and perform two tasks:

i. Fill the blanks marked using seekg(), seekp(), tellp() and tellg() functions for performing the required task. (Hint: please read the comments for missing statement)

ii. Find the errors from given below code, correct the code and after correction write-down the output of this code.

Let assume the input file is contain on that sentence Object-oriented programming is a programming paradigm based on the concept of "objects", which can contain data and code: data in the form of fields, and code, in the form of procedures.

#include

#include

using namespace std;

int main()

{

ifstream F;

F.open("input.txt", ios::in | ios::out);

cout << F.tellg() << endl;

F.seekp(8);

cout << F.tellg() << endl;

char c = F.getline();

cout << c << endl;

cout << F.tellp() << endl;

F.seekg();

cout << F.tellg() << endl;n

c = F.get(c);

cout << c << endl;

cout << F.tellg() << endl;

F.seekp(7, ios::beg);

F.put('Z');

// now, seeking back 7 bytes/characters from the end

F (-7, ios::end);

// now, printing the current location

cout << "End:" << F << endl;

c = F.getline();

cout << c << endl;

F.close(c);

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!