Go Down

Topic: An array of char to a char (Read 760 times) previous topic - next topic

metRo_

Hi,

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

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"){
   ....
   ....
}

mem

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

metRo_

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") ?

AlphaBeta

Quote
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 :)

metRo_

thanks :)

That fubction have better performance then a FOR cycle?

mem

#5
Jul 04, 2009, 07:27 pm Last Edit: Jul 04, 2009, 07:28 pm by mem Reason: 1
I expect you would not notice any difference in performance between calling strcmp and doing an explicit compare in a for loop

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy