Chinaunix

标题: sscanf函数的参数format中,%p是什么意思? [打印本页]

作者: daidaoke    时间: 2003-03-27 17:22
标题: sscanf函数的参数format中,%p是什么意思?
一条语句:
sscanf(s, "%p", &at);

s是一个字符串,at是void *,这句程序是什么意思?
man sscanf里都没有%p的解释?


谢谢!
作者: wangz    时间: 2003-03-27 18:33
标题: sscanf函数的参数format中,%p是什么意思?
p          A sequence of unsigned hexadecimal numbers is expected.  This sequence may be produced by the conversion character of printf.  The corresponding argument shall be a pointer to a pointer to void into  which the value represented by the hexadecimal sequence is stored.  The behavior of this conversion is undefined for any input item other than a value converted earlier during the same program execution.
作者: 无双    时间: 2003-03-27 18:39
标题: sscanf函数的参数format中,%p是什么意思?
...scanf Type Characters
The information in this table is based on the assumption that no optional
characters, specifiers, or modifiers (*, width, or size) were included in
the format specifier.

■ NOTE: Certain conventions accompany some of these format specifiers.

   Type │                    │
   Char │ Expected input     │ Type of argument
═══════╧════════════════════╧═════
  Numerics
═══════╤════════════════════╤═════
   d    │ Decimal integer    │ Pointer to int (int *arg)
   D    │ Decimal integer    │ Pointer to long (long *arg)
   e, E │ Floating point     │ Pointer to float (float *arg)
   f    │ Floating point     │ Pointer to float (float *arg)
   g, G │ Floating point     │ Pointer to float (float *arg)
   o    │ Octal integer      │ Pointer to int (int *arg)
   O    │ Octal integer      │ Pointer to long (long *arg)
   i    │ Decimal, octal, or │ Pointer to int (int *arg)
         │ hexadecimal integer│
    I    │ Decimal, octal, or │ Pointer to long (long *arg)
         │ hexadecimal integer│
    u    │ Unsigned decimal   │ Pointer to unsigned int
         │ integer            │ (unsigned int *arg)
    U    │ Unsigned decimal   │ Pointer to unsigned long
         │ integer            │ (unsigned long *arg)
    x    │ Hexadecimal integer│ Pointer to int (int *arg)
    X    │ Hexadecimal integer│ Pointer to long (long *arg)
  ═══════╧════════════════════╧═════
   Characters
  ═══════╤════════════════════╤═════
    s    │ Character string   │ Pointer to array of chars (char arg[])
    c    │ Character          │ Pointer to char (char *arg) if a field width
         │                    │ W is given along with the c-type character
         │                    │ (such as %5c)
         │                    │ Pointer to array of W chars (char arg[W])
    %    │ % character        │ No conversion done; the % is stored
  ═══════╧════════════════════╧═════
   Pointers
  ═══════╤════════════════════╤═════
    n    │                    │ Pointer to int (int *arg). The number
         │                    │ of characters read successfully up to %n
         │                    │ is stored in this int.
    p    │ Hexadecimal form   │ Pointer to an object (far* or near*)
         │ YYYY:ZZZZ or       │ %p conversions default to the pointer
         │ ZZZZ               │ size native to the memory model
作者: slg1972    时间: 2003-03-27 20:48
标题: sscanf函数的参数format中,%p是什么意思?
ansi c里有很详细的解释,要用qq:16629385联系(中文版)
作者: HopeCao    时间: 2003-03-28 09:01
标题: sscanf函数的参数format中,%p是什么意思?
这是我以前发过的:
http://chinaunix.net/forum/viewtopic.php?t=24825&highlight=




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2