Hey i want to make program which search in string if there is same word ex. "This word is the same word ". And it should outpout this string with changed console color when it encounters the same word . And is there any function or anything to compare them like that ? Because i know how to compare previous word but idk how to do it for my program.
Sry for my english.
Read : "Hey i want to make program which search in string if there is same word ex. "This word is the same word ". And it should outpout this string with changed console color when it encounters the same word . And is there any function or anything to compare them like that ?" Btw no i haven't written any code regarding that yet . Only function that asks for input a string.
@TarikNeaj I didn't even meant that.. I DON'T want to compare string but i want to compare WORDS in string.
Say i wrote as input an string : "This word is the same word" . And i want to outpout the same string but changing the color of console when it encounters "word" because "word" is repeated two times .
Now i splitted string into words but i have last question . How to compare words ex if i have inputted string "Words repeated words" (i have function to split it into words) then how to make algorithm to recognize that someone repeated words ? Iterate through vector and ??
are you asking how to record what words were written? i suggest using std::map. ie:
std::map<std::string, int>, so then you can do this: some_map[current_word]++