[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
CLinkingError » CppConstructor » PCI-X » WirelessToolKit » CompareCppBuilderWithDelphi » CFopen » WhatLinksHere » PDS » QbasicFAQ_PrintControlCodes » Paul Allen » CppCin

(C++) cin

Meaning 'Console In', as opposite of cout. Can be used get input from the user.

Note that std::cin is not always intuitive to work with as a newbie (see e.g. the example). You might want to use std::getline instead.

Example

  1. include <iostream>
int main() { std::cout << "Please type an integer value" << std::endl; int value = 0; std::cin >> value; std::cout << "You typed: " << value << std::endl; std::cout << "Please enter character to exit program" << std::endl; std::cin.clear(); //First clear std::cin std::cin.get(); std::cin.get(); //Yes indeed! This method is needed TWICE! }


Code links



last edited (November 11, 2006) by bilderbikkel, Number of views: 7996, Current Rev: 7 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Site Management by Lars Hagelin at Kontantkort.se.