Go Down

Topic: Addition of sprintf() function in reference page (Read 4298 times) previous topic - next topic


Aug 09, 2010, 07:47 pm Last Edit: Aug 09, 2010, 07:53 pm by mike1588 Reason: 1

I've been using the sprintf() function extensively for the past few months in order to put together sensor-dependent string commands for various serial communication devices.

For those of you not familiar with the function, it takes strings and puts them together. For example, if you run the function with the parameters:
sprintf(combinedText, "Current temperature is %i degrees.", temperature);

It will take the text and add the temperature integer where the %i is. It will then store it in the string called combinedText.

Now, I know that the Arduino language inherits a lot of C++ functions, and sprintf() is only one of them, but as an interaction designer I believe it would be extremely useful to the community members that are not familiar with traditional C-inherited functions.

Perhaps documentation for this function would be more appropriate in the extended library reference?

Please let me know if anyone else thinks this function would be useful to have in the Arduino reference page and I will happily take on the task of writing an Arduino-styled documentation page for this function!



springf? I've heard of sprintf, but not springf.


Whoops, sorry! I meant sprintf().
Sorry, I've had a long day at work  :)



You are right about the documentation. I just now found out about the existence of sprintf() in Arduino. Why is it not documented?


I just now found out about the existence of sprintf() in Arduino. Why is it not documented?

I went to google and type sprintf. I got
About 4,710,000 results (0.10 seconds)

Looks to me like it's documented.

If you mean why isn't it described here:
It's because the Arduino is programmed in C++ which is a superset of C, so (almost) every C function works on Arduino. There are exceptions, like fopen(), where the function is dependent on resources that the Arduino doesn't have, but there aren't that many of them.


Yes, I meant documented on http://arduino.cc/en/Reference/HomePage

But a lot of the other functions on the reference page is also standard C functions and statements, so it does not seem logic to exclude for example sprintf.

At least they should put a note saying something like: Note that you can use most of the standard C functions in your sketch; only a few of them are documented below.

Being new to Arduino, I thought that it had a very limited C version consisting of only the mentioned functions.


do keep in mind that there is a difference between the c/c++ language and the libraries that traditionally come with it.  

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131