[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppCin
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.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
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
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! }
- include <iostream>
Code links
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
