If there any way that I can write a function that will accept multiple datatypes?This is what I am trying to do:I want a function that I can pass either a string of characters or an integer or an object and it will treat it as a stream of bytes so that I can write them out to the serial port one byte at a time. The function will also include things like byte stuffing, but I can deal with that later.

I remember that there was an EEPROMWriteAnything function that used template <class> and things like that but I can't figure out how to adapt it to my needs. I tried and all I get is errors; things like "expected ',' or '...' before '&' token" and "error: ISO C++ forbids declaration of 'T' with no type"

If there any way that I can write a function that will accept multiple datatypes?

Function overloading is really just syntactic sugar for having multiple functions with the same name but different formal parameter lists. Name mangling behind the scenes ensures the linker can tell them apart, but they are all really completely different functions, of course.

If you really want just a single function, you could consider passing a void pointer to your function that holds the address of your variable/array/structure. You would have to pass a second argument as well to tell the function how many bytes the variable/array/structure holds. Defining a macro using sizeof() might be a neat solution for passing the second argument automatically.

Less coding and less flash memory than overloading.

Edit: Oops, just saw Coding Badly already did this. Must read more carefully before posting next time!

Apologies, Nick. Those were actually the errors I got when I tried to compile my sketch with the EEPROMWriteAnything function in it. Word for word, copied and pasted. I just didn't make it clear. Sorry. Just finished a night shift.

So, which approach should I use? Passing a void pointer or writing multiple functions?