How to compare one char with character in string?

I want to perform the following but get an error.

if (Payload[0] = "S")
{
do something
}

There are plenty of examples of comparing strings with strings but cant find any comparing just one character.

Also Payload is an array of characters without a terminating null.

I'm sure there's a simple solution but I can't find it.

I want to perform the following but get an error.

In the future, it would be helpful to say what the error is. It might not mean anything to you, but it might to us.

This code:

if (Payload[0] = "S")
{
  do something      
}

has three problems.

The first is that "S" is a string, of length one. It can not be compared to a character. On the other hand, 'S' is a character, and can be compared to Payload[0].

The second is that = is an assignment operator. The equality comparison operator is ==.

The third is that "do something" is not valid syntax. I'll assume you left off the comment indicator.

So, the code should look like:

if (Payload[0] == 'S')
{
  // do something      
}
if (Payload[0] [glow]==[/glow] [glow]'[/glow]S[glow]'[/glow])
{
  do something      
}

should do it.

Andrew

Edit: Damn, beaten to it.

Thanks guys for the prompt reponse.

The old "=" vs "==" error.
I should have known better.

Cheers