Quantcast
Channel: how to find a substring or string literal - Stack Overflow
Browsing index pages (3 articles)

how to find a substring or string literal

I am trying to write a code that will search userInput for the word "darn" and if it is found, print out "Censored". if it is not found, it will just print out the userInput. It works in some cases,...

View Article


Answer by NathanOliver for how to find a substring or string literal

The problem here is your condition. std::string::find returns a object of std::string::size_type which is an unsigned integer type. That means it can never be less than 0 which meansif...

View Article


Answer by Richard Hodges for how to find a substring or string literal

std::search and std::string::replace were made for this:#include <iostream>#include <string>#include <algorithm>using namespace std;int main() { string userInput; userInput = "That...

View Article
Browsing index pages (3 articles)


Latest Images