Wednesday, September 2, 2009

Operations with inputstreams

cin >> variable

Reads the next word from the stream, interprets it as the same type as the variable and saves the value into the variable. The variable can be of any basic type or string.


cin.get()

Reads and returns the next character in the stream. At the end of input EOF is returned.


cin.get( chr )

Reads the next character into the parameter that must be of the type char.


getline( cin, str )

Reads a line of input from the stream and saves it into a parameter of the type string.


getline( cin, str, chr )

Like above but reads only until meets the first character matching chr.


cin.ignore( how_many, chr )

Reads at most how_many characters from the stream or until meets the first chr. The read characters are "thrown away". How_many is of the type int and chr char.


cin.peek()

Returns the next character in the stream. The character is not read from the stream but the next read operations return it also Returns EOF at the end of input.

Reference: cplusplus, augustcouncil, elcel

Previous post

Next post


4 comments:

shahan said...

ki Eamon, koto taka kamaila? :D

eamon said...

ar taka re vi... just started... summer e rater bela kono kaj thake na bole boisha boisha likhi... "kisu taka jodi ashe to kharap ki" - ei chinta kore adsense lagaya disi but it seems those need lots of effort and I am not a geek like that... ami likhe jaitesi magar page rank o bare na, traffic o ashe na... ekta experiment bolte paro :)

Shahan said...

ami majhe majhe click kore jabo ne.
in return, tumio eikhane click koiro majhe majhe:
http://shubuntu.blogspot.com
http://pc-square-config.blogspot.com/

:-p

eamon said...

hahaha... well, korlam already... But eita valo idea na; too risky... rather link exchange kora jay... I will talk about that later :)

Post a Comment