how to compere the value of a variable and a str.

Hi

Iam new to C.
Iam trying to find soom variables in name see this line

if (name == "dsstringnavn0") server << "<B>"<< value << "</B>";

i like to see if name is “dsstringnavn0” and then highlight the value.

The rest works, but the line about dosent work, and i can see that the names i passet to the variable name.

Hope anyone can help me.

void formCmd(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete)
{
  server.httpSuccess();
  server.printP(htmlHead);
  if (type == WebServer::POST)
  {
    bool repeat;
    char name[16], value[16];
    int a;
    a = 0;
    do
    {
      repeat = server.readPOSTparam(name, 16, value, 16);
      server << a << " = " << name << " = " << value << "
";
      if (name == "dsstringnavn0") server << "<B>"<< value << "</B>";
      a++;
    } while (repeat);

    server << "</body></html>";
  }
}

And this is the result of the about lines.

0 = day = 19
1 = month = 12
2 = year = 2009
3 = time = 01
4 = minutes = 56
5 = dsstringnavn0 = iii
6 = ds0-0 =
7 = dshigh0-0 =
8 = dslow0-0 =
9 = ds0-1 =
10 = dshigh0-1 =
11 = dslow0-1 =
12 = ds0-2 =
13 = dshigh0-2 =
14 = dslow0-2 =
15 = dsstringnavn1 =
16 = dsnavn1-0 =
17 = dshigh1-0 =
18 = dslow1-0 =
19 = dsnavn1-1 =
20 = dshigh1-1 =
21 = dslow1-1 =
22 = dsnavn1-2 =
23 = dshigh1-2 =
24 = dslow1-2 =
25 = dsstringnavn2 =
26 = dsstringnavn3 =

Sorry for my English.

First, your English was fine. It was sufficient to make the point that "name == “dsstringnavn0"” does not perform as you expect.

And why should it, if you think about it. The left side of that comparison is the name of an array. The right side is a literal string. Of course they are not the same, in any way.

I think that you will find that using the strcmp function will do what you want.

if(strcmp(name, "dsstringnavn0") == 0)
   server...

Hi PaulS

Thanks, its not easy when I normal program in pascal :slight_smile:

Bout that do the trick.