Comparing string() vs. string

Hello!

I've just ran in to the following problem:

I have a part of code where I define a string like this:

String freshString(){

String line;


----many thing done here -----


xyz = line,

return line;

Which works well, if I print freshString() to Serial port than I see that it has the value of the line String.

However, later on I have to compare the value of freshString to another "simple" string:

String oldString =("asdf");

if (!(freshString() == oldString){

----do things ----

}

in this case I got the messeage that I want to comapre to different types, which I understand but I don't really know how to get on with this problem.

How canI transform freshString() value to be comparable with "simple" strings? What's the knowhow behind this? I was trying to find info but couldn't succeded.

Please advise!

Please advise!

  1. QUIT USING STRINGS
  2. POST ALL OF YOUR CODE

Yes, I'm screaming at you. Get over it.

  1. What do you mean? use char instead of strings?

  2. right now I can't do it, bcs it isn't here.

Your snippets do not make any sense and you cannot expect good help on bad/partial code. Do not use the "String" class - it uses dynamic memory allocation and it will cause problems at some point. Use old-school char strings and compare with strcmp.

Look through the methods of the String class!

Mark