⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 printf.3int

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 3INT
字号:
.TH printf 3int.SH Name printf, fprintf, sprintf \- print formatted output.SH Syntax .B #include <stdio.h>.PP.B int printf (.I format [, .I arg] ....B ).brchar .IR *format ;.PP.B int fprintf (.IR stream , .IR format [, .I arg] ....B ).br.B FILE .IR *stream ;.br.B char .IR *format ;.PP.B int sprintf (.IR s , .I format[, .I arg] ....B ).br.B char .IR *s , .IR *format ;.SH Description .NXR "printf subroutine".NXR "fprintf subroutine".NXR "sprintf subroutine"The international functions.PN printf ,.PN fprintf ,and.PN sprintf are similar to the .PN printfstandard I/O functions. The difference is that the internationalfunctions allow you to use the .I %digit$ conversion character in place of the .I % character you use in the standard I/O functions. The .I digitis a decimal digit.I nfrom 1 to 9.  The international functions apply conversions to the.I nth argument in the argument list, rather than to the next unused argument..PPYou can use the.I %conversion character in the international functions.  However, you cannotmix the .I %conversion character with the.I %digit$conversion character in a single call..PPYou can indicate a field width or precision by an asterisk (*) instead of adigit string in format strings containing the.I %conversion character. If you use an asterisk, you can supply an integer.I argthat specifies the field width or precision. In format strings containing the.I %digit$conversion character, you can indicate field width or precision by the sequence.I *digit$.You use a decimal digit from 1 to 9 to indicate which argumentcontains an integer that specifies the field width or precision..PPThe conversion characters and their meanings are identical to.PN printf ..PPYou must use each .I digitargument at least once..PPIn all cases, the radix character .PN printfuses is defined by the last successful call to.PN setlocalecategory.PN LC_NUMERIC .If.PN setlocalecategory.PN LC_NUMERIChas not been called successfully or if the radix character is undefined,the radix character defaults to a period (.)..SS International Environment.IP LC_NUMERIC 15If this environment is set and valid, .PN printfuses the international language database named in the definition todetermine radix character rules..IP LANG 15If this environment variable is set and valid .PN printfuses the international language database named in the definition todetermine collation and character classification rules.  If.PN LC_NUMERIC is defined, its definition supercedes the definition ofLANG..SH Examples The following example illustrates using an argument to specify field width:.EX 0printf ("%1$d:%2$.*3$d:%4$.*3$d\\n",				hour, min, precision, sec);.EEThe format string \fI*3$\fP indicates that the third argument, whichis named precision, contains the integer field width specification..PPTo print the language independent date and time format use the following.PN printfstatement:.EXprintf (format, weekday, month, day, hour, min);.EEFor American use,.I formatcould be a pointer to the following string:.EX"%1$s,  %2$s %3$d, %4$d:%5$.2d\\n".EEThis string gives the following date format:.EXSunday, July 3, 10:02.EEFor use in a German environment, .I formatcould be a pointer to the following string:.EX"%1$s, %3$d. %2$s, %4$d:%5$.2d\\n".EEThisstring gives the following date format:.EXSonntag, 3. Juli, 10:02.EE.SH Return Values.NXR "printf subroutine" "System V and".PN printf and .PN fprintf return zero for success and EOF for failure.  The.PN sprintf subroutine returns its first argument for success and EOF for failure..PPIn the System V and POSIX environments, .PN printf ,.PN fprintf, and.PN sprintfreturn the number of characters transmitted for success.  The.PN sprintffunction ignores the null terminator (\\0) when calculating the numberof characters transmitted.  If an output error occurs, these routinesreturn a negative value..SH See Also intro(3int), setlocale(3), scanf(3int), printf(3s), putc(3s), scanf(3s), stdio(3s).br .I Guide to Developing International Software

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -