--%>

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 a Sub class Sub class : It is a

    Sub class: It is a class which extends its super class. The sub-class inherits all the members of its super class. All Java classes are the sub-classes of Object class, which is at the root of inheritance hierarchy.

  • Q : Define Swapping Swapping : An

    Swapping: An {operating system} is frequently able to run programs which need more memory than is physically accessible on the host system. In order to do this, the complete memory needed is broken down into smaller pieces that are swapped in whenever

  • Q : Define Protocol Protocol : It is a set

    Protocol: It is a set of rules for interaction between two processes. The protocol is generally specified in a Uniform Resource Locator (abbreviated as URL) to point out how a specific resource must be transferred from a Web server to the requesting c

  • Q : Define several features of XQuery

    Define several features of XQuery?

  • Q : What is no-arg constructor no-arg

    no-arg constructor: It is a constructor which takes no arguments. By default, each and every class without an explicit constructor has a default no-arg constructor with the public access. Its role is entirely to invoke the no-arg constructor of the in

  • Q : Explain Polymorphism Polymorphism : It

    Polymorphism: It is the ability of an object reference to be employed as if it referred to an object with various forms. The polymorphism in Java outcomes from both class inheritance and interface inheritance. The actually different forms frequently o

  • Q : Explain the way of the Orbeon Explain

    Explain the way of the Orbeon.

  • Q : Features and advantages of UNIX Specify

    Specify the features and advantages of the UNIX?

  • Q : Define the term Top level class Define

    Define the term Top level class: It is a class defined either at outermost level of a package or the static nested class.

  • Q : What is Linux Write down about Linux?

    Write down about Linux?