peak in c++
C++
// istream::peek example
#include <iostream> // std::cin, std::cout
#include <string> // std::string
#include <cctype> // std::isdigit
int main () {
std::cout << "Please, enter a number or a word: ";
std::cout.flush(); // ensure output is written
std::cin >> std::ws; // eat up any leading white spaces
int c = std::cin.peek(); // peek character
if ( c == EOF ) return 1;
if ( std::isdigit(c) )
{
int n;
std::cin >> n;
std::cout << "You entered the number: " << n << '\n';
}
else
{
std::string str;
std::cin >> str;
std::cout << "You entered the word: " << str << '\n';
}
return 0;
}
Also in C++:
- Title
- C++ w3schools
- Category
- C++
- Title
- split string at index c++
- Category
- C++
- Title
- properties of a set c++
- Category
- C++
- Title
- friend function in c++
- Category
- C++
- Title
- char* to int in cpp
- Category
- C++
- Title
- hohw toparse a string in c++
- Category
- C++
- Title
- char size length c++
- Category
- C++
- Title
- c++ program for addition of two numbers using functions
- Category
- C++
- Title
- count a character in a string c++
- Category
- C++
- Title
- how to delete an element in vector pair in cpp
- Category
- C++
- Title
- convert string to stream c++
- Category
- C++
- Title
- binary representation differ in bits
- Category
- C++
- Title
- c++ replace n substrings
- Category
- C++
- Title
- c++ transform
- Category
- C++
- Title
- c++ cli convert string to string^
- Category
- C++
- Title
- object reference not set to an instance of an object c#
- Category
- C++
- Title
- how print fload wiht 3 decimal in c++
- Category
- C++
- Title
- new in c++
- Category
- C++
- Title
- range based for loop c++ with reference
- Category
- C++
- Title
- first prime numbers
- Category
- C++
- Title
- c++ string^ to char*
- Category
- C++
- Title
- c++ raw string
- Category
- C++
- Title
- c++ unittest in ros
- Category
- C++
- Title
- delete 2d dynamic array c++
- Category
- C++
- Title
- how to load from files C++
- Category
- C++
- Title
- singleton c++
- Category
- C++
- Title
- what is time complexity of insertion sort
- Category
- C++
- Title
- how to print eachh chars in string data type in c++
- Category
- C++
- Title
- how to check type in c++
- Category
- C++
- Title
- how to find the number of cycles in a graph C++
- Category
- C++
- Title
- calculate factorial
- Category
- C++
- Title
- switch statement c++
- Category
- C++
- Title
- what is sigsegv error in c++
- Category
- C++
- Title
- namespace file linking c++
- Category
- C++
- Title
- double ended queue in c++ stl
- Category
- C++
- Title
- shortest path with bfs in c++
- Category
- C++
- Title
- cout console
- Category
- C++
- Title
- c++ std::copy to cout
- Category
- C++
- Title
- c++ while true
- Category
- C++
- Title
- how to inject a dll into a game c++
- Category
- C++
- Title
- body parser
- Category
- C++
- Title
- c++ show time elapsed
- Category
- C++
- Title
- what is meaning of 64 bit integer in c++
- Category
- C++
- Title
- regexp_like oracle c++
- Category
- C++
- Title
- mysqli connect
- Category
- C++
- Title
- how to print nth palindrome number in c++
- Category
- C++
- Title
- sort function in c++
- Category
- C++
- Title
- how to check datatype of a variable in c++
- Category
- C++
- Title
- c++ how to loop through a vector but not the last element
- Category
- C++
- Title
- sub string of vector c++
- Category
- C++
- Title
- zeros of array c++
- Category
- C++
- Title
- convert char to string - c++
- Category
- C++
- Title
- #include
- Category
- C++
- Title
- free or delete in c++
- Category
- C++
- Title
- formal parameter c++
- Category
- C++
- Title
- c++ multiple inheritance diamond problem
- Category
- C++
- Title
- cut by delimiter c++
- Category
- C++
- Title
- cube mapping sdl
- Category
- C++
- Title
- UPARAM(ref)
- Category
- C++
- Title
- compare function in sort c++ stl
- Category
- C++
- Title
- swapo algorit
- Category
- C++
- Title
- how to delete something in an array c++
- Category
- C++
- Title
- c++ function return array
- Category
- C++
- Title
- matrix multiplication c++ eigen
- Category
- C++
- Title
- binary tree search
- Category
- C++
- Title
- create a dictionary cpp
- Category
- C++
- Title
- C++ If
- Category
- C++
- Title
- bitset c++
- Category
- C++
- Title
- simple timer arduino blynk library error
- Category
- C++
- Title
- new keyword in cpp
- Category
- C++
- Title
- sort a pair using c++ stl
- Category
- C++
- Title
- binary search stl in c++
- Category
- C++
- Title
- minmax_element c++
- Category
- C++
- Title
- uepic games github
- Category
- C++
- Title
- maximum possible number atmost k swaps
- Category
- C++
- Title
- can you use a return to print a string when referencing an integer c++
- Category
- C++
- Title
- pop from between string c++
- Category
- C++
- Title
- to_string c++
- Category
- C++
- Title
- how to execute c++ program in cmd
- Category
- C++
- Title
- floor() in c++
- Category
- C++
- Title
- remove from unordered_set c++
- Category
- C++
- Title
- fill c++
- Category
- C++
- Title
- how to remove maximum number of characters in c++ cin,ignore
- Category
- C++
- Title
- c++ yes no question
- Category
- C++
- Title
- graph using djacency matrix c++
- Category
- C++
- Title
- c++ template function
- Category
- C++
- Title
- date to string c++
- Category
- C++
- Title
- std::substring
- Category
- C++
- Title
- centos7 mlock2
- Category
- C++
- Title
- cpp pi from acos
- Category
- C++
- Title
- c++ char print fixed
- Category
- C++
- Title
- c++ call method in same class
- Category
- C++
- Title
- list conda environments
- Category
- C++
- Title
- gta san andreas
- Category
- C++
- Title
- declaration vs. definition cpp
- Category
- C++
- Title
- cannot jump from switch statement to this case label c++
- Category
- C++
- Title
- c++ map insert
- Category
- C++
- Title
- how to iterate trough a vector in c++
- Category
- C++
- Title
- repeating character in c++
- Category
- C++
- Title
- how are graphics in games made
- Category
- C++