Question about language translator program

I created a conlang before (constructed language), and now I am learning C++, so I decided to program a translator. I was going to go about it with strings, and I could just have it translate single words, but I want it to translate sentences. Is there a way that I could have the program tell if there are multiple words in one string? I'm guessing using strings limits it to just translating words and phrases directly without being able to decipher multiple words. Also, I don't really need the sentences to switch around, because grammar doesn't matter much. I'd like to keep it simple, too, and attempt to use only strings, arrays, or any other basic commands, but I'll step outside the beginner box if I have to.
Search for whitespaces, they usually separate words from one another. Also operator >> usually extracts only single words from input stream.
Last edited on
So for example if I were to translate I in English to Yo in Spanish, would I create a char for the word I, and then do operator >> I;, then cout << "yo"? I don't have too much knowledge of c++, so I'm assuming there's more to it than that.
You should do like:
* Take word from input.
* Search for it translation in dictionary
* Output translation
Ok, I just figured it out, I'm doing this:
std::string eegus (" i");
unsigned i = in.find(eegus);
if (i!=std::string::npos)
std::cout << " eegus";
That finds the word in the string and then translates it. In this case it translates "i" to "eegus".
Topic archived. No new replies allowed.