How to find the position of the first word in a string that starts with a specific letter in C++

1 Answer

0 votes
#include <iostream>
#include <algorithm>   

int main() {
    std::string str = "java c++ c# python c";
    
    std::size_t pos = str.find_first_of('c');
    
    std::cout << pos;
}



/*
run:

5

*/

 



answered Aug 16, 2024 by avibootz
...