--%>

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 Public interface Public

    Public interface: The members of a class prefixed with public access modifier. All these members are visible to each and every class in a program.

  • Q : Explain Assignment operator Assignment

    Assignment operator: The operator (=) employed to store the value of an expression into the variable, for example: Variable = expression; The right-hand

  • Q : Tower of Hanoi Puzzle program using C#

    here I attached the assignment and examples of how can you do this assignments. I will post others in the next week as well.

  • Q : Non linear dynamic model equation to

    Could you please show the steps from non linear dynamic model equation to linear equation?

  • Q : What is an Object Object : It is an

    Object: It is an instance of a particular class. In common, any number of objects might be constructed from a class definition. The class to which an object belongs states the common characteristics of all instances of that class. In those characteris

  • Q : Monte Carol method to estimate pi An

    An interesting way to estimate pi can can done using Monte Carol method with minimal mathematics. Monte Carlo is known for its casinos. A Monte Carlo method uses change, or in our case, random numbers to simulate the real situation. The situation we simulate here is t

  • Q : Determining group ID of new file

    Explain various options available in order to determine the group ID of new file?

  • Q : Define Object serialization Object

    Object serialization: The writing of an object's contents in such a manner that its state can be restored, either at a later time, or in a different procedure. This can be employed to store objects between runs of a program, or to transfer or shifts o

  • Q : Aren't HTML Aren't HTML, SGML, and XML

    Aren't HTML, SGML, and XML all very similar things?

  • Q : What is Pattern Pattern : It is a

    Pattern: It is a recurring theme in class usage or design. Interfaces like Iterator encapsulate a pattern of admission to the items in a collection, whereas freeing the client from the requirement to know details of the way in which the collection is