c语言scanf d n,scanf("%*[^\n]%*c");这是什么意思?

这个和unix下的正则表达式很相似

[ ]表示选择,^表示非

这里的*是忽略

The format specification controls how the arguments are converted for assignment. The percent sign (%) indicates the start of a conversion specification. Except for the conversion specifications and white space, other characters in the format have to match the input. If a character doesn't match, processing stops, leaving the remainder of the input unread.

There are three optional components to a conversion specification, shown in square brackets below:

%[*][fldwidth][lenmodifier]convtype

The optional leading asterisk is used to suppress conversion. Input is converted as specified by the rest of the conversion specification, but the result is not stored in an argument.

The fldwidth component specifies the maximum field width in characters. The lenmodifier component specifies the size of the argument to be initialized with the result of the conversion. The same length modifiers supported by the printf family of functions are supported by the scanf family of functions (see Figure 5.8 for a list of the length modifiers).

The convtype field is similar to the conversion type field used by the printf family, but there are some differences. One difference is that results that are stored in unsigned types can optionally be signed on input. For example, 1 will scan as 4294967295 into an unsigned integer. Figure 5.10 summarizes the conversion types supported by the scanf family of functions.

Conversion  type       Description

d                      signed decimal, base 10

i                      signed decimal, base determined by format of input

o                      unsigned octal (input optionally signed)

u                      unsigned decimal, base 10 (input optionally signed)

x                      unsigned hexadecimal (input optionally signed)

a,A,e,E,f,F,g,G           floating-point number

c                      character (with l length modifier, wide character)

s                      string (with l length modifier, wide character string)

[                      matches a sequence of listed characters, ending with ]

[^                     matches all characters except the ones listed, ending with ]

p                     pointer to a void

n                     pointer to a signed integer into which is written the number of characters read so far

%                     a % character

C                     wide character (an XSI extension, equivalent to lc)

S                     wide character string (an XSI extension, equivalent to ls)

6f83fddf9cb9ff6843fffd45e1807199.gif

为了防止世界被破坏,为了守护世界的和平,贯彻爱与真实的邪恶,可爱又迷人的反派角色,VxWorks!

Don't ask me any question.I'm just here to buy soy sauce.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值