Dotcpp  >  编程教程  >  stdio.h头文件  >  C语言printf()函数:产生格式化输出的函数

C语言printf()函数:产生格式化输出的函数

点击打开在线编译器,边学边练

函数名: printf

头文件:<stdio.h>

函数原型: int printf(char *format...);

功 能: 产生格式化输出的函数

参数:char *format...  要输出的格式

返回值:成功  返回写入的字符总数 ,失败  返回一个负数。


程序例: 将数字10按照十进制、八进制、十六进制的形式以及不同的长度输出

#include<stdio.h>

#include<string.h>

#define I 555

#define R 5.5

int main(void){

   int a=10;

   printf("%d,%o,%x\n",a,a,a);

   printf("%5d\n",a);

   return 0;

}

 

运行结果

10,12,a
   10



本文固定URL:https://www.dotcpp.com/course/524

C语言函数库
assert.h头文件
ctype.h头文件
float.h头文件
io.h头文件
math.h头文件
mem.h头文件
setjmp.h头文件
stdio.h头文件
stdlib.h头文件
sigal.h头文件
string.h头文件
time.h头文件
Dotcpp在线编译      (登录可减少运行等待时间)