Код: Выделить всё
#include <iostream>
#include <string>
int main() {
std::string str = "Hello, world!";
std::string substring = "world";
if (str.find(substring) != std::string::npos) {
std::cout << "Подстрока найдена!" << std::endl;
} else {
std::cout << "Подстрока не найдена." << std::endl;
}
return 0;
}
Код: Выделить всё
#include <iostream>
#include <string>
int main() {
// Объявляем массив символов (строку)
char charArray[] = "Hello, world!";
// Приводим массив символов к типу std::string
std::string str(charArray);
// Выводим строку
std::cout << str << std::endl;
return 0;
}