例子 printf-hello
#include "stdio.h"
main()
{
printf("Hello, world\n");
}
例子 prinf-常量
#include "stdio.h"
#include "conio.h"
main()
{
printf("%d\n",5);
printf("%d\n",236);
printf("%d\n",847);
printf("%d\n",5847);
printf("%d\n",3695847);
printf("%ld\n",3695847);
printf("%f\n",3.1415926);
printf("%c\n",'h');
printf("%s\n","abc");
getch();
}
例子 printf变量
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
int iutu;
int intValue;
int intCatNo;
int XueHao;
int xue_hao;
int i_5=0;
int i2=-2;
int a,b,c;
int i,j,k;
int x=3,y=5,z=0;
int xa=121;
char cc='t';
float f=6.2;
printf("hi,monday!\n");
printf("%d\n",98);
printf("%f\n",3.26);
printf("%c\n",'H');
printf("%s\n","constant string ,这个中文固定不变");
printf("%d\n",xa);
printf("%f\n",f);
printf("%c\n",cc);
printf("%d\n",xa*2);
printf("%f\n",f+1.6);
printf("%c\n",cc-3);
}
例子 scanf输入数据
#include "stdio.h"
#include "conio.h"
int main(){
char str;
scanf("%c",&str);
printf("%d",str);
getch();
}