Created
April 3, 2020 22:36
-
-
Save asa55/fb21b2db63011430497f03811aa1b6ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How do you check if a string contains only digits? | |
#include <iostream> | |
#include <string> | |
#include <algorithm> | |
std::string your_string = "012345678774829506432X"; | |
std::string my_set = "0123456789"; | |
std::string::iterator it = my_set.begin(); | |
auto main () -> int | |
{ | |
for ( auto el : your_string ) | |
{ | |
it = std::find( my_set.begin(), my_set.end(), el ); | |
if ( it == my_set.end()) | |
std::cout << "el out of set found" << std::endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment