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 <david.br...@hesbynett.no> wrote:
sprintf((A_String + i), "%c", 0xff)
has exactly the same effect as:
A_String[i] = 0xff;
A_String[i + 1] = 0x00;
delay_about_1000_processor_cycles();
waste_about_2000_bytes_of_code_space();
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.
_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list