天天看点

C格式化输入、输出C格式化输入C格式化输出

C格式化输入

例句:

sscanf(xml, "%*[^0-9^-]%f", &speed);

解析:

  • %*

    : 表示忽略后面匹配的内容, 不要求后面加接收者的指针;
  • %m

    : 表示函数自行分配空间来存储, 用后释放;
  • %[]

    : 匹配一串字符. For instance,

    [^]0-9-]

    means the set “everything except close bracket, zero throughnine, and hyphen”

C格式化输出

%u

%d

一样的规则:

  • %d

    当做int32输出
  • %hd

    当做int16输出
  • %hhd

    当做int8输出
  • %ld

    当做long输出
  • %lld

    当做long long输出

继续阅读