Converting any uint/byte/char array type to a const char array type?

This is the issue:

  1. I have a function that takes a "const char *" input, the header of the function is like this:
void writeFile(fs::FS &fs, const char * path, const char * message)
  1. I have some data stored into different arrays (time_t, uint32_t and what not). I can transform this into "char" arrays like this:
time_t timestamp = get_rtctime();
//Getting my timestamp into char:
uint32_t tStmp_32 = (uint32_t)timestamp;
char timeStr[32];
snprintf(timeStr, sizeof timeStr, "%08X", tStmp_32);

Until this point, no problems at all.

  1. Converting uint or char to const char, the way is supposed to for writeFile to accept it without errors.

???

I'm not sure how to pull that part of. Is it possible? If so, how can it be performed?

Thanks for any guidance you can provide :slight_smile:

I have a function

Is it part of a library ?

Yes indeed,

It belongs to the SD library from ESP32, this is taken from an example used in this script:

ajpaezm:
Until this point, no problems at all.
3) Converting uint or char to const char, the way is supposed to for writeFile to accept it without errors.

Any function that accepts an argument of type "const char *" will also accept a "char *". On function arguments the 'const' just means "I promise I won't use this pointer to write into your data."
Note: There is no type "uint". Did you mean "unsigned int" or "uint_16"?

Hi johnwasser!

Any function that accepts an argument of type "const char *" will also accept a "char *". On function arguments the 'const' just means "I promise I won't use this pointer to write into your data."
Note: There is no type "uint". Did you mean "unsigned int" or "uint_16"?

I thought the same, just sending that input there but for some reason this has not worked (later on when I try again I'll post the outcome here).

And I apologise about the "uint" type, I was just trying to be general on the unsigned integer types you could declare, like uint16_t, uint8_t, uint32_t, etc.

The methods using unions and memcpy() will get a different result on different machines.