Код: Выделить всё
#include <iostream>
#include <string>
int main() {
std::string str = "Привет, мир!";
std::string subStr = "мир";
// Находим подстроку
size_t found = str.find(subStr);
if (found != std::string::npos) {
std::cout << "Подстрока '" << subStr << "' найдена на позиции: " << found << std::endl;
} else {
std::cout << "Подстрока '" << subStr << "' не найдена." << std::endl;
}
return 0;
}
Код: Выделить всё
size_t found = str.find(subStr, start_pos);