Put and get functions

The function get () is a member function of the file stream class f stream, and is used to read a single character from the file. The function put () is a member function of the output stream class f stream, and is used to write a single character from the output file. The programme give below reads strings from the standard input device, and writes the same to a file character by character. A sequential file is developed and its pointer is placed at the start of the file. It is processed in sequence till the end of file is reached.

Programme in C++, writes and reads characters from the file

# include < f. Stream .h >     

Void main ()

{

Char C, string [75];

F stream file ("student. Txt", ios : : in / ios : : out);

Cout << "enter string :";

  Cin. Get line (string, 74);

For (Int I = 0, string [I]; I++)

File. Put (string [I]);   // writes a character

File. Seek g (0);            // seek to the beginning

Cout << "output string : ";

While (file)               // reads a character

{

File. Get (C);

 Cout << c;

}

}

   Related Questions in Programming Languages

  • Q : What is SLAM SLAM is a Microsoft

    SLAM is a Microsoft project that blurs the line between static analysis and model checking and deductive reasoning. The main goal of SLAM is to check temporal safety properties of C programs (it actually checks that a program correctly uses the interf

  • Q : Define Uniform Resource Locator Uniform

    Uniform Resource Locator: It is a Uniform Resource Locator (abbreviated as URL) expands the concept of file access from a wholly local context to one in which the resources are named uniformly, irrespective of where they may be physically situated. A

  • Q : System Architecture for Windows

    Tell me about the System Architecture for Windows Programming?

  • Q : State the term Web application State

    State the term Web application?

  • Q : Define the term Case label Case label :

    Case label: The value utilized to select a specific case in a switch statement.

  • Q : What is Bandera Bandera: The main goal

    Bandera: The main goal of Bandera project is to integrate existing programming language processing methods with newly developed methods to provide automated support for the extraction of safe, compact, finite-state models which are suitable for verifi

  • Q : What is applet? Explain life cycle of

    Ans. Applet: An applet is an application designed to travel over the internet and to be executed on the client machine by a java compatible

  • Q : Microsoft Access I have attached a

    I have attached a database and a PDF with 5 questions. I need the 5 questions answered with 5 queries in the database. Question 3 needs a crosstab query. All the questions require the proper join.

  • Q : Define the term Blank final variable

    Blank final variable: A final variable which is not initialized as portion of its declaration. This variable should be initialized in either an instance initialization block or every of the constructors for its class before it is employed. A static bl

  • Q : Explain Aggregation Aggregation : It is

    Aggregation: It is a relationship in which an object has one or more other subordinate objects as portion of its state. The subordinate objects usually have no self-governing existence separate from their containing object. Whenever the containing obj

©TutorsGlobe All rights reserved 2022-2023.