-5

Could we do something like this?

char word = "violet";

if ("vi" in word)
{
  (do something);
}

Or is there any other way to do it?

3
  • 6
    Does this answer your question? Check substring exists in a string in C Commented Oct 15, 2020 at 14:40
  • 1
    I suspect that the string handling chapter of a C programming book may reveal the answer. Just as the array chapter before it revealed that strings are character arrays char word[] = .... Commented Oct 15, 2020 at 14:43
  • 1
    Why is this closed as a duplicate of a question asking about finding a single character when OP is looking for a longer substring? Commented Oct 15, 2020 at 15:33

1 Answer 1

0

Not quite, but you could write

if (strstr("violet", "vi")){
    // do something
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.