String to String


Sorry, I am fairly new to C++ when it comes to dealing with something like a GUI. I have pretty much everything working, but I can’t seem to compare my std::string to the juce::String. Is there a way to do this? My teacher said it was fine to use the GUI but I can’t use your special functions for reading in files and such soooo… that has to be done the long way (which is of course understandable for learning reasons). Here is an example of what I am trying to do:

uname is a TextEditor and (*start) is an iterator going through a liststd::string

if(uname->getText() == (*start)->getUsername())

The compiler says that I can’t compare the two, but I was thinking if I could change one to std::string or the other way around then it should work. BUT! I can’t seem to figure out how to do it.


std::string to String:

  std::string s;
  String js (s.c_str ());

String to std::string

  String js;
  std::string s (js.toUTF8 ());

Funny because less than 5 minutes ago I was writing this exact code!


Awesome! Thanks, works like a charm.