Setting variables to a text value

I'm about at my wit's end on this and I can't find any information on how to accomplish this EXTREMELY SIMPLE THING. Here's what I want to do:

  if (isPM()){
    AMPM = "PM";
  }

I've tried initializing AMPM as char, char*, byte - even some of the numerical data types. I get an error no matter what data type I try. Why is it so hard in Arduino to set a variable to a sting of text? This is ridiculous.

Someone please point me to the obvious and simple answer that everyone but me seems to know.

Thanks.

koyaanisqatsi:
I've tried initializing AMPM as char, char*, byte - even some of the numerical data types.

Works for me...

void setup( void )
{
}

bool isPM( void )
{
return( random( 2 ) == 1 );
}

void loop( void )
{
char* AMPM;

if (isPM()){
AMPM = "PM";
}
}

Unbelievable. (Inconceivable!)

I've been fighting with this for the last hour and a half. And it works for me too, the way you typed it. It must have been a syntax error. The compiler errors did not indicate such.

Thank you!

You need to show the whole thing (bit late now, but next time). The way you declared the variable would affect it. And the error messages would be useful to see.

Why is it so hard in Arduino to set a variable to a sting of text? This is ridiculous.

It's C++. Not "Arduino". You need to get certain things right. If you get in a car and jam your foot on the brake, it doesn't go forwards, right? That's not ridiculous. It's user error.

Read this before posting a programming question

I see. Thanks.