📄 scanf.3
字号:
1694(integer)S1999(is)S2091(expected;)S2502(the)S(corresponding)575 2650 A3250(argument)S(should)267 3655 A3947(be)S4067(an)S4187(integer)S4492(pointer.)S5496 V10 B1080(o)S10 R1280(an)S1400(octal)S1621(integer)S1926(is)S2018(expected;)S2429(the)S(corresponding)575 2577 A3177(argument)S(should)267 3582 A3874(be)S3994(a)S4064(integer)S4369(pointer.)S5664 V10 B1080(x)S10 R1280(a)S1350(hexadecimal)S1884(integer)S2189(is)S2281(expected;)S2692(the)S(corresponding)575 2840 A3440(argument)S(should)267 3845 A4137(be)S4257(an)S4377(integer)S4682(pointer.)S5832 V10 B1080(s)S10 R1280(a)S1356(character)S1758(string)S2018(is)S2116(expected;)S2533(the)S(corresponding)575 2687 A3293(argument)S(should)267 3704 A4003(be)S4130(a)S4207(character)S4610(pointer)S4927(pointing)S5952 V1280(to)S1394(an)S1525(array)S1769(of)S1888(characters)S2333(large)S(enough)295 2570 A2900(to)S(accept)258 3013 A3306(the)S3464(string)S3728(and)S3908(a)S3988(terminating)S4487(`\\0',)S4693(which)S(will)157 4974 A5166(be)S6072 V1280(added.)S1595(The)S(input)206 1777 A2008(\256eld)S2212(is)S2304(terminated)S2760(by)S2885(a)S(space)224 2955 A3204(character)S3600(or)S3709(a)S3779(newline.)S6240 V10 B1080(c)S10 R1280(a)S1361(character)S1768(is)S1872(expected;)S2295(the)S(corresponding)575 2455 A3067(argument)S(should)267 3484 A3788(be)S3920(a)S4002(character)S4410(pointer.)S4782(The)S4976(normal)S6360 V1280(skip)S1488(over)S(space)224 1708 A1973(characters)S2424(is)S(suppressed)441 2531 A3012(in)S3130(this)S3315(case;)S3557(to)S3675(read)S3889(the)S4052(next)S(non-space)408 4265 A4713(character,)S5149(try)S6480 V1280(`%1s'.)S1598(If)S1693(a)S1765(\256eld)S1972(width)S2229(is)S2324(given,)S2600(the)S(corresponding)575 2751 A3354(argument)S(should)267 3762 A4057(refer)S4277(to)S4383(a)S4456(character)S4855(array,)S5116(and)S6600 V1280(the)S1428(indicated)S1822(number)S2154(of)S2263(characters)S2698(is)S2790(read.)S6768 V10 B1080(efg)S10 R1280(a)S1353(\257oating)S1688(point)S1922(number)S2257(is)S2352(expected;)S2766(the)S2917(next)S3118(\256eld)S3325(is)S(converted)397 3420 A(accordingly)475 3845 A4348(and)S4522(stored)S(through)312 4797 A5138(the)S6888 V(corresponding)575 1280 A1885(argument,)S2320(which)S(should)267 2595 A2891(be)S3015(a)S3089(pointer)S3403(to)S3510(a)S10 B3584(\257oat)S10 R3774(.)S3853(The)S(input)206 4039 A4274(format)S4572(for)S4719(\257oating)S5055(point)S7008 V1280(numbers)S1658(is)S1757(an)S1884(optionally)S2323(signed)S2617(string)S2879(of)S2996(digits)S3252(possibly)S3619(containing)S4076(a)S4154(decimal)S4506(point,)S4770(followed)S5161(by)S7128 V1280(an)S1400(optional)S(exponent)368 1754 A2147(\256eld)S2351(consisting)S2783(of)S2892(an)S3012(E)S3099(or)S3208(e)S3278(followed)S3661(by)S3786(an)S3906(optionally)S4338(signed)S4625(integer.)S7296 V10 B1080([)S10 R1280(indicates)S1667(a)S1741(string)S1999(not)S2156(to)S2263(be)S2387(delimited)S2796(by)S(space)224 2925 A3178(characters.)S3667(The)S3853(left)S4018(bracket)S4345(is)S4442(followed)S4830(by)S4960(a)S5035(set)S5177(of)S7416 V1280(characters)S1719(and)S1893(a)S1967(right)S2186(bracket;)S2540(the)S2692(characters)S3131(between)S3496(the)S3648(brackets)S4013(de\256ne)S4288(a)S4362(set)S4503(of)S4616(characters)S5054(mak-)S7536 V1280(ing)S1440(up)S1572(the)S1727(string.)S2038(If)S2138(the)S2293(\256rst)S2482(character)S2885(is)S2984(not)S3144(circum\257ex)S3607(\()S3657(\303)S3707(\),)S3798(the)S(input)206 3953 A4191(\256eld)S4402(is)S4501(all)S4634(characters)S(until)184 5077 A7903 V720(Page)S941(1)S2669(\()S2711(May)S2920(15,)S(1985)200 3070 A3278(\))S4455(September)S4911(13,)S(1996)200 5061 A8143 VEP%%Page: 2 2BP/slant 0 def/height 0 def480 V10 R720(SCANF)S1053(\()S1095(3)S1153(\))S2696(Eighth)S(Edition)296 2989 A4794(SCANF)S5127(\()S5169(3)S5227(\))S960 V1280(the)S1429(\256rst)S1612(character)S2009(not)S2163(in)S2267(the)S2416(set)S2554(between)S2916(the)S3065(brackets;)S3455(if)S3543(the)S3691(\256rst)S3873(character)S4269(after)S4480(the)S4628(left)S4788(bracket)S5110(is)S5202(\303,)S1080 V1280(the)S(input)206 1434 A1671(\256eld)S1881(is)S1979(all)S2111(characters)S(until)184 2552 A2767(the)S2921(\256rst)S3109(character)S3511(which)S3788(is)S3886(in)S3996(the)S4151(remaining)S4591(set)S4735(of)S4851(characters)S1200 V1280(between)S1641(the)S1789(brackets.)S2200(The)S(corresponding)575 2382 A2982(argument)S3387(must)S3607(point)S3838(to)S3941(a)S4011(character)S4407(array.)S1368 V1080(The)S(conversion)441 1269 A1742(characters)S10 B2184(d)S10 R2240(,)S10 B2297(o)S10 R2379(and)S10 B2556(x)S10 R2638(may)S2843(be)S2970(capitalized)S3439(or)S(preceded)364 3555 A3951(by)S10 B4083(l)S10 R4143(to)S4253(indicate)S4604(that)S4787(a)S4865(pointer)S5183(to)S1488 V10 B1080(long)S10 R1290(rather)S1552(than)S1751(to)S10 B1855(int)S10 R1999(is)S2092(in)S2196(the)S2345(argument)S2751(list.)S2950(Similarly,)S3376(the)S(conversion)441 3525 A3992(characters)S10 B4428(e)S10 R4473(,)S10 B4524(f)S10 R4584(or)S10 B4694(g)S10 R4769(may)S4967(be)S5087(cap-)S1608 V1080(italized)S1405(or)S(preceded)364 1517 A1909(by)S10 B2037(l)S10 R2093(to)S2199(indicate)S2546(a)S2619(pointer)S2932(to)S10 B3038(double)S10 R3357(rather)S3621(than)S3822(to)S10 B3928(\257oat)S10 R4118(.)S4196(The)S(conversion)441 4381 A4851(characters)S1728 V10 B1080(d)S10 R1136(,)S10 B1186(o)S10 R1261(and)S10 B1431(x)S10 R1506(may)S1704(be)S(preceded)364 1824 A2213(by)S10 B2338(h)S10 R2419(to)S2522(indicate)S2866(a)S2936(pointer)S3246(to)S10 B3349(short)S10 R3598(rather)S3859(than)S4057(to)S10 B4160(int)S10 R4278(.)S1896 V1080(The)S10 B1267(scanf)S10 R1521(functions)S1925(return)S2196(the)S2349(number)S2686(of)S(successfully)492 2801 A3324(matched)S3696(and)S3872(assigned)S(input)206 4249 A4486(items.)S4785(This)S4995(can)S5166(be)S2016 V1080(used)S1301(to)S1415(decide)S1714(how)S1923(many)S(input)206 2182 A2424(items)S2678(were)S(found.)259 2911 A3231(The)S3424(constant)S9 B3793(EOF)S10 R4015(is)S4118(returned)S(upon)200 4490 A4726(end)S4907(of)S(input;)234 5027 A2136 V1080(note)S1302(that)S1502(this)S1696(is)S1812(different)S2209(from)S2454(0,)S2578(which)S2873(means)S3179(that)S3380(no)S(conversion)441 3530 A4021(was)S(done;)223 4228 A4501(if)S(conversion)441 4613 A5104(was)S2256 V1080(intended,)S1476(it)S1557(was)S1739(frustrated)S2151(by)S2276(an)S2396(inappropriate)S2958(character)S3354(in)S3457(the)S(input.)231 3605 A2424 V1080(For)S1245(example,)S1636(the)S1784(call)S2592 V1580(int)S1711(i;)S1792(\257oat)S1996(x;)S2099(char)S2298(name[50];)S2712 V1580(scanf\("%d%f%s",)S2334(&i,)S2490(&x,)S2668(name\);)S2880 V1080(with)S1284(the)S(input)206 1432 A1663(line)S3048 V1440(25)S1615(54.32E)S10 Y1902(-)S10 R1957(1)S2057(thompson)S3216 V(will)157 1080 A1262(assign)S1538(to)S10 B1641(i)S10 R1694(the)S1842(value)S2085(25,)S10 B2235(x)S10 R2310(the)S2458(value)S(5.432,)250 2701 A2976(and)S10 B3146(name)S10 R(will)157 3406 A3588(contain)S3909(`)S10 B3943(thompson\\0)S10 R4446(')S4505(.)S4580(Or,)S3384 V1440(int)S1571(i;)S1652(float)S1862(x;)S1965(char)S2164(name[50];)S3504 V(scanf\("%2d%f%*d%[1234567890]",)1492 1440 A2957(&i,)S3113(&x,)S3291(name\);)S3672 V1080(with)S(input)206 1284 A3840 V(56789)250 1440 A(0123)200 1715 A1940(56a72)S4008 V(will)157 1080 A1278(assign)S1570(56)S1711(to)S10 B1830(i)S10 R1858(,)S(789.0)225 1924 A2190(to)S10 B2309(x)S10 R2359(,)S2425(skip)S(`0123',)293 2633 A2968(and)S(place)213 3155 A3410(the)S3575(string)S3846(`56\\0')S4134(in)S10 B4254(name)S10 R4489(.)S4581(The)S4780(next)S4995(call)S5183(to)S4128 V10 B1080(getchar)S10 R(will)157 1430 A1612(return)S1878(`a'.)S4296 V9 R720(S)S722(SE)S774(EE)S832(E)S913(A)S915(AL)S983(LS)S1041(SO)S1093(O)S4416 V10 B1080(atof)S10 R1248(\(3\),)S10 B1416(getc)S10 R1590(\(3\),)S10 B1758(printf)S10 R2011(\(3\),)S10 B2179(stdarg)S10 R2453(\(3\).)S4584 V9 R720(D)S722(DI)S790(IA)S823(AG)S891(GN)S959(NO)S1027(OS)S1095(ST)S1147(TI)S1205(IC)S1238(CS)S1300(S)S4704 V10 R1080(The)S10 B1262(scanf)S10 R1511(functions)S1910(return)S9 B2174(EOF)S10 R2385(on)S2510(end)S2680(of)S(input,)231 2789 A3045(and)S3215(a)S3285(short)S(count)223 3511 A3759(for)S3902(missing)S4239(or)S(illegal)252 4348 A4625(data)S4818(items.)S4872 V9 R720(B)S722(BU)S784(UG)S852(GS)S920(S)S4992 V10 R1080(The)S(success)302 1262 A1589(of)S(literal)236 1698 A1959(matches)S2314(and)S(suppressed)441 2484 A2950(assignments)S3466(is)S3558(not)S3711(directly)S4044(determinable.)S7903 V720(September)S1176(13,)S(1996)200 1326 A2669(\()S2711(May)S2920(15,)S(1985)200 3070 A3278(\))S4990(Page)S5211(2)S8143 VEP%%Trailer%%DocumentFonts: Times-Roman Times-Bold Times-Italic Symbol%%Pages: 2
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -