sizeof vs. strlen and passing a char array to a function

I'm not much of a C programmer, so please bear with me... I had a question concerning these two functions... I know one returns the size of the actual variable, in the case of a string, it's the number of characters plus the null ending, but something seems weird to me, since when I ask for a sizeof a char array I passed to a function, it faithfully says 2. strlen reports properly. I think I'm missing something very fundamental. Can somebody explain/direct? See enclosed code and results. This isn't my exact code of course, but it reproduces the same results.
Thank you!
Andy

void setup() {
Serial.begin(9600);
Serial.println("Running now...");
}

void loop() {
  wigglewiggle("1");
  delay(1000);
  wigglewiggle("123");
  delay(1000);
  wigglewiggle("1234567890");
  delay(1000); 
  wigglewiggle("Noodle doodle weeble wobble boodle poodle");
  delay(1000);
  wigglewiggle("GRRR!");
  delay (5000);
}

void wigglewiggle(char letters[]) {
Serial.println ("Testing: " + String(letters));
Serial.println("sizeof says it's " + String(sizeof(letters)));
Serial.println("strlen says it's " + String(strlen(letters)));
Serial.println(""); 
}

Running now...
Testing: 1
sizeof says it's 2
strlen says it's 1

Testing: 123
sizeof says it's 2
strlen says it's 3

Testing: 1234567890
sizeof says it's 2
strlen says it's 10

Testing: Noodle doodle weeble wobble boodle poodle
sizeof says it's 2
strlen says it's 41

Testing: GRRR!
sizeof says it's 2
strlen says it's 5

'wigglewiggle' single parameter, 'letters', is actually of type 'char*', or pointer and as such is 2 bytes on the majority of Arduino boards.

So I guess what I need to do here is be able to pass a string of various lengths to that function, but now I see it's giving me all sorts of grief because I have no idea what I'm doing with pointers and so forth - For example, say I want to implement a FOR loop to output the strings "cheezburger1,cheezburger2,cheezburger3,cheezburger4" to my function.. OK I know these are all the same length, but maybe I also want to output different lengths too... It works great when I'm just sending hard coded text, but how do I manipulate this?

Basically, I just need to have something akin to the 'serial.print' and be able to pass data in to it like that.. whatever I want.....uh oh... does this mean I need to learn how to write a class??

Andy

I'm not quite following as ...

'Serial.println("strlen says it's " + String(strlen(letters)));'

... seems to give you what you need.

OK - Here's what I'm actually doing... I have a bunch of custom dot matrix shift register lighting blah blah.. It's a character display, 128 bulbs in four groupings of 32. I have all of that stuff worked out, the hardware is gorgeous. It's the fact that I learned BASIC 25 years ago..and I'm 'tarded.

In my actual program, if I use

writeTime("ABCD");
writeTime("1234");

everything is great. Problem is, how do I put incrementing numeric values in there? In other words... say... turn HOURS in to a string, MINUTES in to a string, then squash them together and output a 4 byte string to this function? I know for strictly numbers I could just pass a numeric value and this would be easy, but I kinda need to talk to this function like LCD or Serial to have it work the way I want it... and I have the sinking feeling that I'm going about it all wrong.

void writeTime (char letters[]){
  //This is only part of the program
  
  int X;
  Serial.println("Size of letters is " + String(strlen(letters)));
if (debug == true){  Serial.println ("Deconstructing " + String(letters));}
  digitalWrite(latchPin, LOW); // Drop the latch.
  for (int X = 0; X < strlen(letters); X ++){
  
  // Now, map ASCII values to our fonts.
  byte A = (selectChar(letters[X]));
  
  // Now start outputting to the shift registers
    
   shiftOut(dataPin, clockPin, LSBFIRST, font[A][3]);
   shiftOut(dataPin, clockPin, LSBFIRST, font[A][2]);
   shiftOut(dataPin, clockPin, LSBFIRST, font[A][1]);
   shiftOut(dataPin, clockPin, LSBFIRST, font[A][0]);
   
  }
  
  digitalWrite(latchPin, HIGH); // Raise the latch.
   

}

this works rather well

void func(char* string) {
  Serial.println(string);
}
//….
int hours, minutes;
char buf[64]; // create a place for the string to go
sprintf(buf, "%2d:%2d", hours, minutes);
// buf now contains hours and minutes with a colon in between, each at least 2 digits long with leading 0 if necessary
func(buf);

Seems like I may have some luck with this... though it seems like I'm getting a leading "null" instead of a leading "0"
I think we're looking for sprintf(buf, "%02d:%02d", hours, minutes);

HOWEVER... that was not the breakthrough.

void writeTime2 (char* letters){

THAT was. That little * - It used to be void writeTime2 (char letters[]){

PS, sprintf is awesome. Why does Arduino make no mention of this?

Thanks a million. Mark this one solved!

Sorry, you're right. Although you really should say "space" rather than "null" because a null means a binary 0 while a space is 32, and there's ASCII 0 which is different.

HOWEVER... that was not the breakthrough.

void writeTime2 (char* letters){

THAT was. That little * - It used to be void writeTime2 (char letters[]){

really? I thought there was no difference between the two, just different forms of the same thing.

PS, sprintf is awesome. Why does Arduino make no mention of this?

It's nice. If you're annoyed about having to make a buffer if you're just going to print it to the serial or an lcd or something you can use fprintf without a character buffer easily: avr-libc: <stdio.h>: Standard IO facilities