Pages: [1]   Go Down
Author Topic: Addition of sprintf() function in reference page  (Read 2975 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

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!

Cheers,
Mike
« Last Edit: August 09, 2010, 12:53:29 pm by mike1588 » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 631
Posts: 50115
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Mike
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 49
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 631
Posts: 50115
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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
Quote
About 4,710,000 results (0.10 seconds)
Looks to me like it's documented.

If you mean why isn't it described here:
http://arduino.cc/en/Reference/HomePage
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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 49
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 41
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: