CodeClerks

getlin() FUNCTION IN C++



Write the reason you're deleting this FAQ

getlin() FUNCTION IN C++

Wecan read and display a line of text more efficiently using and line-oriented
input function getline(). The getline() function reads a whole lineof text that ends with a newline character (transmitted by the RETURN key).
This function can be invoked by using the object cin as follows:


cin.getline (line, size);


This function call invokes the function getline() which reads character input into the variable line. The reading is terminated
as soon as either the newline character ‘n’ is encountered or size-1 characters are read (whichever occurs first). The newline character is read but not saved. Instead, it is replaced by
the null character. For example, consider the following code:


#include

 

usingnamespace std;

 

intmain()

{

            int size = 20;

            char city[20];

 

            cut > city;

            cout

Comments

Please login or sign up to leave a comment

Join