An array of char to a char

Hi,

I have an array of char (char cmd[]="1234":wink: and i want to convert it to a char (char cmd1="1234":wink:

I need to compare the char. If i'm using an array i need to use a for but i want to use something like:

if(cmd1 == "1234"){
....
....
}

see the strcmp function: http://www.cplusplus.com/reference/clibrary/cstring/strcmp/

  1. Can i use that function on Arduino?

  2. Can i compare an array of char (char cmd[5]="1234") with a char (cmd1="1234") ?

  1. Can i use that function on Arduino?

  2. Can i compare an array of char (char cmd[5]="1234") with a char (cmd1="1234") ?

Yes and yes :slight_smile:

thanks :slight_smile:

That fubction have better performance then a FOR cycle?

I expect you would not notice any difference in performance between calling strcmp and doing an explicit compare in a for loop