conditional on a *char? Need help with syntax

I'm using the CC300o and Adafruit server library to set up a web server for simple control though different web paths that I send along.

The var path is a *char (char pointer).

When I access the server with http://xxx.xxx.x.xx/b the following will show Path: /b

Serial.print(F("Path: ")); Serial.println(path);

so we know that /b is stored in *path.

my question is how would I accomplish the following:

if(path == '/b')
{
//do something
}

Also in this case I only need the 2nd char so the following would cool to know how to accomplish:

if(path[1] == 'b')
{
//do something
}

I've gotten the sketch to work with:

String pathString = String(path);
if(pathString == "/b")
{
val = 'b';
}

but I'd rather not have the overhead of the String class if I don't need it.

THANKS!!!!!!

check out strcmp() string compare
http://www.cplusplus.com/reference/cstring/strcmp/

also strstr() to find the position of a substring ...
http://www.cplusplus.com/reference/cstring/strstr/

but I'd rather not have the overhead of the String class if I don't need it.

The var path is a *char (char pointer).

So you have a function that returns the path, and this function returns a char *?

If that is the case, the char * can be used without the need of the String class, ie:

if( !strcmp( path, "/b" ) )
{

}

// or if path contains a lot more data before or after that string:

if( strstr( path, "/b" ))
{

}

if( !strcmp( path, "/b" ) )
{

}

That worked like a champ tammytam! THANKS!!!!

While I have it fresh in my mind I'd like to ask this also, as it's the next step in my project...

Let's sat I start with 3 ints...

int val1;
int val2;
int val3;

now in this path *char I populate it with 9 numbers. For example...

I access http://xxx.xxx.x.xx/123456789

resulting in *path = /123456789

how would I parse this to:

val1 = 123
val2 = 456
val3 = 789

Thanks again!

I'm using a server library that returns a *char of the path I try to access.

for example if I access http://xxx.xxx.x.xx/123456789

resulting in *path = /123456789

Let's sat I start with 3 ints...

int val1;
int val2;
int val3;

how would I parse this to:

val1 = 123
val2 = 456
val3 = 789

The format would always be 9 numbers.

Thanks again!

This is a little bit of a hack, but it should work:

void setup() {
  // put your setup code here, to run once:
  char *path = "/123456789";
  char buff[4];      // Need room for null
  int i;
  int index = 0;
  int vals[3];
  int max = strlen(path);
   
  Serial.begin(9600);
 
  for (i = 1; i < max; i += 3) {
    strncpy(buff, &path[i], 3);
    vals[index++] = atoi(buff);
  }
  for (i = 0; i < 3; i++)
  {
    Serial.println(vals[i]);
  }    
}

void loop() {
  // put your main code here, to run repeatedly:

}