Finding C++ very corn-fusing

I am struggling with this...

The Wind Direction only gets read every second transmission cycle so I need to be able to set the wthrWindDir = 'X' on the non-read cycle;

When I use this in a function it prints the appropriate letter 'A' through 'P'. Serial.print(getWindDirection_Descr(dataBytes[4]));

But, when I do this is prints a back-to-front "?" for the value. wthrWindDir = getWindDirection_Descr(dataBytes[4]); Serial.print(wthrWindDir); if wthrWindDir != 'X' ...

I realize this is non-working code, but I am sure it is a procedural thing that I am not grasping -- again! :)

Full code is here. https://forum.arduino.cc/index.php?topic=528352.msg3601988#msg3601988

char wthrWindDir   = 'X';

const float winddirections[] = {
  315.0, 247.5, 292.5, 270.0,
  337.5, 225.0, 0.0, 202.5,
  67.5, 135.0, 90.0, 112.5,
  45.0, 157.5, 22.5, 180.0
};

char * acurite_5n1_winddirection_str[] = {
  "A",  // 0  315
  "B",  // 1  247.5
  "C",  // 2  292.5
  "D",  // 3  270
  "E",  // 4  337.5
  "F",  // 5  225
  "G",  // 6  0
  "H",  // 7  202.5
  "I",  // 8  67.5
  "J",  // 9  135
  "K",  // 10 90
  "L",  // 11 112.5
  "M",  // 12 45
  "N",  // 13 157.5
  "O",  // 14 22.5
  "P"   // 15 180
};

char * getWindDirection_Descr(byte b) {
  int direction = b & 0x0F;
  return acurite_5n1_winddirection_str[direction];
}

I had a Dream last night: In it a poster actually included his complete program with the question

The getWindDirection_Descr() function returns a pointer to a global string. When you print that, Serial.print() knows how to print the data pointed to.

When you store the pointer in the wrong kind of variable, the right version of Serial.print() is not selected, since the selected version is based on the type of variable.

Store the output of the function in the right kind of variable, and you will be able to Serial.print() the variable.

  char *windDir = getWindDirection_Descr(dataBytes[4]);
   Serial.print("Wind direction: ");
   Serial.println(windDir);

UKHeliBob: I had a Dream last night: In it a poster actually included his complete program with the question

That's a grand dream, but, in the case, the OP did actually post enough code.

232: In short - reality is "real engineers do not read manuals" so you may as well give up or just keep (day) dreaming.

Nope. Reality is amateurs don't read manuals. Real engineers can't afford to waste time (theirs and other people's) by not using all the information that's available.

Steve

Why people reply " google it"!
DO NOT SHOUT!
Post full code!
What does it do?
First read “how to post”…
etc.

Because a properly presented question is easier to answer

UKHeliBob: Because a properly presented question is easier to answer

And if my time is limited (which it is) then it makes sense to use it helping someone who takes the trouble to make it easy to help them.

...R

232: If you cannot decipher the post , you do have a choice to ignore it. People, especially beginners , should be given credit for how they post without arrogant criticism of it. Most of them will figure it out on their own why they are not getting help they expect.

karma++

and if you your "time is limited" and help causes you "trouble" then don't hang around a forum!!

PaulS: The getWindDirection_Descr() function returns a pointer to a global string. When you print that, Serial.print() knows how to print the data pointed to.

When you store the pointer in the wrong kind of variable, the right version of Serial.print() is not selected, since the selected version is based on the type of variable.

Store the output of the function in the right kind of variable, and you will be able to Serial.print() the variable.

  char *windDir = getWindDirection_Descr(dataBytes[4]);
   Serial.print("Wind direction: ");
   Serial.println(windDir);

Ahhh, so simple, thank you Paul, very much appreciated. I only use C++ in Arduino, the rest of my entire programming efforts are with Pascal and Assembler. In the roughly four times a year that I foray into C++, the memory (mine) sags badly.

If you cannot decipher the post , you do have a choice to ignore it.

or to provide advice as to how to provide more information in order that the question posed can be better understood.