user-0 提问: C语言数组的一个小问题

回复:
user: user-1
content: scanf Type Field Characters The type character is the only required format field; it appears after any optional format fields. The type character determines whether the associated argument is interpreted as a character, string, or number.  Table R.8   Type Characters for scanf functions  Character  Type of Input Expected Type of Argument  c When used with scanf functions, specifies single-byte character; when used with wscanf functions, specifies wide character. White-space characters that are ordinarily skipped are read when c is specified. To read next non–white-space single-byte character, use %1s; to read next non–white-space wide character, use %1ws. Pointer to char when used with scanf functions, pointer to wchar_t when used with wscanf functions.  C When used with scanf functions, specifies wide character; when used with wscanf functions, specifies single-byte character. White-space characters that are ordinarily skipped are read when C is specified. To read next non–white-space single-byte character, use %1s; to read next non–white-space wide character, use %1ws. Pointer to wchar_t when used with scanf functions, pointer to char when used with wscanf functions.  d Decimal integer. Pointer to int.  i Decimal, hexadecimal, or octal integer. Pointer to int.  o Octal integer. Pointer to int.  u Unsigned decimal integer. Pointer to unsigned int.  x Hexadecimal integer. Pointer to int.  e, E, f, g, G Floating-point value consisting of optional sign (+ or –), series of one or more decimal digits containing decimal point, and optional exponent (“e” or “E”) followed by an optionally signed integer value. Pointer to float.  n No input read from stream or buffer. Pointer to int, into which is stored number of characters successfully read from stream or buffer up to that point in current call to scanf functions or wscanf functions.  s String, up to first white-space character (space, tab or newline). To read strings not delimited by space characters, use set of square brackets ([ ]), as discussed following Table R.7. When used with scanf functions, signifies single-byte character array; when used with wscanf functions, signifies wide-character array. In either case, character array must be large enough for input field plus terminating null character, which is automatically appended.  S String, up to first white-space character (space, tab or newline). To read strings not delimited by space characters, use set of square brackets ([ ]), as discussed preceding this table. When used with scanf functions, signifies wide-character array; when used with wscanf functions, signifies single-byte–character array. In either case, character array must be large enough for input field plus terminating null character, which is automatically appended.    The types c, C, s, and S are Microsoft extensions and are not ANSI-compatible.   Thus, to read single-byte or wide characters with scanf functions and wscanf functions, use format specifiers as follows.  To Read Character As Use This Function With These Format Specifiers  single byte scanf functions c, hc, or hC  single byte wscanf functions C, hc, or hC  wide wscanf functions c, lc, or lC  wide scanf functions C, lc, or lC    To scan strings with scanf functions, and wscanf functions, use the prefixes h and l analogously with format type-specifiers s and S.

user: user-0
content: 引用 16 楼 sholber 的回复:请楼主买一本《C标准库》阅读，胜似我们回复帖子3000。呵呵，好的，这就去下载，谢谢你们

user: user-2
content: 请楼主买一本《C标准库》阅读，胜似我们回复帖子3000。

user: user-3
content: 引用 13 楼 u013138790 的回复:引用 12 楼 zhao4zhong1 的回复:十六进制输入用%x%x是八进制吧？十六进制应该是%0x吧？%o 才是八进制  %x 是十六进制

user: user-0
content: 引用 12 楼 zhao4zhong1 的回复:十六进制输入用%x%x是八进制吧？十六进制应该是%0x吧？

user: user-1
content: 十六进制输入用%x

user: user-1
content: 在楼主之前我没见过用%p输入。

user: user-0
content: 引用 9 楼 vcttyys 的回复:因为你的数组b再第二次输入的时候就开始任性了，呵呵，把i++去了试试你好，能问下，去掉i++的话，那么这个数组里面反复输入b[0]了吧？

user: user-4
content: 因为你的数组b再第二次输入的时候就开始任性了，呵呵，把i++去了试试

user: user-0
content: 引用 7 楼 lin5161678 的回复:十六进制用 %x 或 %X  别用什么 %p能弱弱的问下两者有什么区别吗

user: user-3
content: 十六进制用 %x 或 %X  别用什么 %p

user: user-0
content: 引用 5 楼 fly_dragon_fly 的回复:看运气，未初始化的内存为0时就退出来了....................好吧

user: user-5
content: 看运气，未初始化的内存为0时就退出来了

user: user-3
content: 数组太小 第二次输入开始越界

user: user-0
content: 引用 1 楼 focuslight 的回复:scanf("%p", &b);  你这个都存入b[0]  后面顺序内存里是随机值但是我把那个改成scanf("%p", &b[i]);也还是老样子

user: user-0
content: 引用 1 楼 focuslight 的回复:scanf("%p", &b);  你这个都存入b[0]  后面顺序内存里是随机值谢了！

user: user-6
content: scanf("%p", &b);  你这个都存入b[0]  后面顺序内存里是随机值