Converting char* and byte* to something I can understand

Hello,
I'm trying to use MQTT callback to take action based on MQTT topics and payloads. The Arduino MQTT library's callback function looks like this:

void setup() {
client.subscribe("1111");
client.subscribe("2222");
client.subscribe("3333");
}

void callback(char* topic, byte* payload, unsigned int length) {
  Serial.println("Hello!  MQTT message received");
}

I need to convert the char* topic and the byte* payload into something I can do if-statements on. I know my topics names are always four characters (digits) long. And the payloads are either ints or floats depending on the topic name.

How do I convert the char* into an int? How do I conditionally convert the byte* payload into a float?

For the char* to int, I think I would use the atoi(buffer) function, but the buffer is usually a char buffer [ x ] , where x is definite. I don't know what to do with a char*. If I'm always subscribing to the 4-character topic name (1111, 2222, 3333, etc), I can assume char* is 4 characters, but how do I pass char* to atoi() function?

I don't know what to do with byte* to convert it into float. I think the unsigned int length is the size of the payload byte*? But what to do with it?

It might be easier to just treat the topic pointer like an array ( use the subscript operator '[]' to access elements ), and do a strcmp() (compare ) of the string to your saved name. If you really use numbers, you can minus the character '0' off each topic character and you will be left the integer value.

but how do I pass char* to atoi() function?

Every reference I have ever seen for atoi has had an example in it...

For the float, you can look at atof().

EricExperiment:
How do I convert the char* into an int?

char * foo = "4242";

void setup ()
  {
  Serial.begin (115200);
  Serial.println ();

  int bar = atoi (foo);
  Serial.println (bar);
  }  // end of setup

void loop () {}

How do I conditionally convert the byte* payload into a float?

What do you mean by that?

pYro_65:
For the float, you can look at atof().

atof() accepts a string for the parameter. But I have a byte*

Ah, ok. atoi() accept a char*. I didn't know that was the same as a char[]. That works.

I meant to say that I want to convert a byte* to a float. Do I need to first convert a byte* to a char*?

If the byte* string is null-terminated you could just cast it.

byte foo [] = "1234";

void setup ()
  {
  Serial.begin (115200);
  Serial.println ();

  int bar = atoi ((const char *) foo);
  Serial.println (bar);
  }  // end of setup

void loop () {}

I meant to say that I want to convert a byte* to a float. Do I need to first convert a byte* to a char*?

Is the data a string containing a decimal value, "123.45" which is 6 characters or is it 4 bytes which are actually floating point data?