Converting to integer

I’m reading characters in from a web site, putting them in a an array of chars, then converting it into an integer (it’s always an integer).

Whatever the actual number the result comes back as 2289.

This is the relevant code snippet:

char bar[5] = "";
byte foo=0;
  char tmp = client.read();
  while (tmp != '\n') {  //line break signifies end of number
    bar[foo] = tmp;
    tmp = client.read();
    foo++;
  }
  curUzr = int(bar);

That's probably the correct value for the address of your buffer Have you tried 'atoi'?

How do I get the integer value of the string?

you haven't got a string until you terminate it.

Oh. I've added , but it still doesn't work (value has changed though, it's nw 2287). What have I missed?

char bar[5] = "";
byte foo=0;
  char tmp = client.read();
  while (tmp != '\n') {  //line break signifies end of number
    bar[foo] = tmp;
    tmp = client.read();
    foo++;
  }
  char[foo]='\0';
  curUzr = int(bar);

I've just spotted your mention of atoi. What's that?

YES! That's done it. Thank you AWOL :D