Created
April 3, 2020 22:33
-
-
Save asa55/0dcdd4714ac1daf3a7762605e765d000 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 print the first non-repeated character from a string? | |
#include <iostream> | |
#include <string> | |
std::string my_str = "aaaaaaabccccccc"; | |
int main () | |
{ | |
int index; | |
for (index = 0; index < my_str.size() - 1; ++index) | |
if ( my_str[index] != my_str[index + 1] ) break; | |
std::cout << my_str[index + 1] << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment