본문으로 바로가기

C :: 포맷스트링 연습

category Programing/C 2017. 4. 25. 01:20

#include<stdio.h>


void main(){

int num;


printf("/%d/\n",12345);

printf("/%10d/\n",12345);

printf("/%-10d/\n",12345);

printf("/%010d/\n\n",12345);


printf("/%f/\n",12345.678);

printf("/%15f/\n",12345.678);

printf("/%15.2f/\n",12345.678);

printf("/%-15.2f/\n\n",12345.678);


printf("%c %d %c %d \n",'A','A',97,97);

printf("/%s/\n/%10s/\n/%-10s/\n\n","Campus","Campus","Campus");


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

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

printf("%d %#o %#x \n\n",0x67,0x67,0x67);


num = 10;

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


num = -10;

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


}


/12345/

/     12345/

/12345     /

/0000012345/


/12345.678000/

/   12345.678000/

/       12345.68/

/12345.68       /


A 65 a 97 

/Campus/

/    Campus/

/Campus    /


67 0103 0x43 

55 067 0x37 

103 0147 0x67 


10 012 0xa 

-10 037777777766 0xfffffff6