--%>

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 : Define White space White space :

    White space: Characters employed to make visual spacing in a program. White spaces comprise space, tab, carriage return and the line feed characters.

  • Q : Define the term Micro- Processor Define

    Define the term Micro- Processor.

  • Q : Define the term Mutual recursion Define

    Define the term Mutual recursion: Recursion which outcomes from two methods calling one other recursively.

  • Q : Component which are used in 2nd layer

    What are the different types of component parts which are used in 2nd layer?

  • Q : Explain Copy constructor Copy

    Copy constructor: It is a constructor which takes a single argument of similar class. For illustration:     public class Point {        

  • Q : Web based programming homework

    Component 2 Task b: Task Description Computing students at this University who study on undergraduate courses require a method to view their module marks and to see how they are progressing on the module. You have been asked to develop a web

  • Q : Describe Layout manager Layout manager

    Layout manager: The object responsible for sharing the accessible space between multiple components in a graphical container.

  • Q : Computer science 1. Here is a short

    1. Here is a short program. It prints out the value of a variable "x". Ernie and Bert disagree about what will be printed: Ernie says, the value gets changed in "changeX" so it will print "7", and Bert says, no, when the function exits the changes get reversed and the value goes back to "5". Explain

  • Q : Use of XMLHttpRequest object in AJAX

    What is the use of XMLHttpRequest object in AJAX?

  • Q : What is Runtime stack Runtime stack :

    Runtime stack: It is a stack structure maintained by the Java Virtual Machine which records that methods are presently being executed. The most of late entered technique will be at the top of the stack and the main technique of an application will be