搜索
bottom↓
回复: 2

请问在AVR怎么使用printf这样的函数

[复制链接]

出0入0汤圆

发表于 2008-8-21 10:49:55 | 显示全部楼层 |阅读模式
请问在AVR怎么使用printf这样的函数啊?

阿莫论坛20周年了!感谢大家的支持与爱护!!

一只鸟敢站在脆弱的枝条上歇脚,它依仗的不是枝条不会断,而是自己有翅膀,会飞。

出0入22汤圆

发表于 2008-8-22 12:57:20 | 显示全部楼层
来自iccavr的帮助
int printf(char *fmt, ..)

prints out formatted text according to the format specifiers in the fmt string. The format specifiers are a subset of the standard formats. The full conversion specification is:

%[flags]*[width][.precision][l]<conversion character>

The flags are:

#                 - alternate form. For the 'x' or 'X' conversion, a 0x or 0X is generated. For the floating point conversions, a decimal point is generated even if the floating point value is exactly an integer.

- (minus)        - left align the output

+ (plus)        - add a '+' sign character for positive integer output

' ' (space)        - use space as the sign character for positive integer

0                - pad with zero instead of spaces

The width is either a decimal integer or '*', denoting that the value is taken from the next argument. The width specifies the minimal number of characters that will be printed, left or right aligned if needed and padded with either spaces or zeros, depending on the flag characters.

The precision is preceded by a '.' and is either a decimal integer or '*', denoting that the value is taken from the next argument. The precision specifies the minimal number of digits for an integer conversion, the maximum number of characters for the 's' string conversion, and the number of digits after the decimal point for the floating point conversions.

The conversion characters are as follows. If an 'l' (letter el) appears before an integer conversion character, then the argument is taken as a long integer.

%d - prints the next argument as a decimal integer

%o - prints the next argument as an unsigned octal integer

%x - prints the next argument as an unsigned hexadecimal integer

%X - the same as %x except that upper case is used for 'A'-'F'

%u - prints the next argument as an unsigned decimal integer

%s - prints the next argument as a C null terminated string

%c - prints the next argument as an ASCII character

%f - prints the next argument as a floating point number in decimal <aaa>.<bbbb> format

%e, %E - prints the next argument as a floating point number in scientific notation <a>.<bbb>e<exp> format. %e uses small 'e' and %E uses capital 'E'

%g, %G - printfs the next argument as a floating point number in either decimal or scientific notation.

printf is supplied in three versions, depending on your code size and feature requirements (the more features, the higher the code size):

Basic: only %c, %d, %x, %u, and %s format specifiers without modifiers are accepted.
        Long: the long modifiers %ld, %lu, %lx are supported, in addition to the width and precision fields.
        Floating point: all formats including %f for floating point are supported.

The code size is significantly larger as you progress down the list. You select the version to use in the Compiler Options dialog box.

printf returns the number of characters printed.

出0入0汤圆

发表于 2011-9-9 11:23:21 | 显示全部楼层
呵呵,论坛里有很多例子
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-3-29 06:32

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表