zoukankan      html  css  js  c++  java
  • [收藏]使用scanf输入double格式的数据问题

    正确格式为%lf,scanf("%lf",double type variable);

    原文地址:http://www.programfan.com/club/showpost.asp?id=22045&t=o

    ┌────────────────────────────────────────┐
    │  ...scanf Format Specifiers                                                    │
    ├────────────────────────────────────────┤
    │In ...scanf format strings, format specifiers have the following form:          │
    │                                                                                │
    │  % [ * ] [width] [F|N] [h|l|L] pe_char                                         │
    │                                                                                │
    │Each format specifier begins with the percent character (%).                    │
    │                                                                                │
    │After the % come the following, in this order:                                  │
    │                                                                                │
    │┌─────┬────────────────────────────────┐│
    ││Component │What It Is/Does                                                 ││
    │├─────┼────────────────────────────────┤│
    ││ [ * ]    │(Optional) Assignment-suppression character                     ││
    ││          │Suppresses assignment of the next input field.                  ││
    ││ [width]  │(Optional) Width specifier                                      ││
    ││          │Specifies maximum number of characters to read; fewer           ││
    ││          │characters might be read if the ...scanf function encounters    ││
    ││          │a whitespace or unconvertible character.                        ││
    ││ [F|N]    │(Optional) Pointer size modifier                                ││
    ││          │Overrides default size of address argument:                     ││
    ││          │  N = near pointer                                              ││
    ││          │  F = far pointer                                               ││
    ││ [h|l|L]  │(Optional) Argument-type modifier                               ││
    ││          │Overrides default type of address argument:                     ││
    ││          │  h = short int                                                 ││
    ││          │  l = long int, if type_char specifies integer conversion       ││
    ││          │  l = double, if type_char specifies floating-point conversion  ││
    ││          │  L = long double, (valid only with floating-point conversion)  ││
    ││ type_char│(Required) Type character                                       ││
    │└─────┴────────────────────────────────┘│
    └────────────────────────────────────────┘

  • 相关阅读:
    如果看了此文你还不懂傅里叶变换,那就过来掐死我吧【完整版】(ZZ伯乐在线)
    探索推荐引擎内部的秘密,第 2 部分: 深入推荐引擎相关算法
    Slope One :简单高效的协同过滤算法(Collaborative Filtering)(ZZ)
    非常的好的协同过滤入门文章(ZZ)
    防止rm误操作的方法(zz)
    CentOS使用YUM安装Adobe Flash Player
    今天尝试dd命令制作CentOS启动优盘
    关于php中,POST方法接收不到内容
    linux系统下使用vim 显示行号~
    打开php的错误提示
  • 原文地址:https://www.cnblogs.com/oyjj/p/2132974.html
Copyright © 2011-2022 走看看