[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] Re: sprintf

From: David Brown
Subject: [avr-gcc-list] Re: sprintf
Date: Sat, 28 Feb 2009 20:49:07 +0100
User-agent: Thunderbird (Windows/20081209)

Daniel O'Connor wrote:
On Saturday 28 February 2009 09:00:50 David Kelly wrote:
On Fri, Feb 27, 2009 at 10:37:30PM +0100, Vincent Trouilliez wrote:
On Fri, 27 Feb 2009 22:10:16 +0100

David Brown <address@hidden> wrote:
        sprintf((A_String + i), "%c", 0xff)

has exactly the same effect as:

        A_String[i] = 0xff;
        A_String[i + 1] = 0x00;
ROTF ! :-))))
sprintf() only costs 2kB? Sure enough, this little program is 2132 bytes
after strip:

Depends which vprintf you ask for, see http://www.nongnu.org/avr-libc/user-manual/group__avr__stdio.html#ga3b98c0d17b35642c0f3e4649092b9f1

Also, while it IS a pig (relative to the micro flash size and CPU) it is
very powerful and for a lot of applications the speed is not critical.

I didn't mean to imply that there is a problem with sprintf itself - I've had occasion to use it in my own programs. The point is that it is totally inappropriate in this case - not only is direct access to the array hugely smaller and faster, but it is very much clearer to write and easier to understand.

When you want to use the features of sprintf (and friends) for text and number formatting, then it is much easier and faster than writing your own code.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]