% 를 만나기 전까지 출력% 를 만나면 서식지정자에 따라 분기int → char )int*, double*, char*) :가변인자와 %의 개수가 일치하지 않을 경우 : printf는 개수가 일치하지 않아도 길이를 반환하지만 나는 컴파일러에서 잡아주는 것(warning)을 생각해서 -1을 리턴하도록 했다.
%cint%schar *%p0x + 12자리 / 64비트 시스템)void * → unsigned long longunsigned 정수형중 void * 의 사이즈보다 큰 자료형으로 맞춰주도록 하자.sizeof(void*) ? 운영체제에 맞게 받을 수 있도록 해주면 어떨까 생각했지만 위처럼 큰 자료형을 맞춰주는 게 더 간단할 것 같다. printf("%p", ap); // 0x7ff7b12f4560 : 2 + 12
printf("%p", (void *)-1); // 0xffffffffffffffff : 2 + 16%d %iinttest.c:7:18: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
printf("%i", 2147483648);
~~ ^~~~~~~~~~
%li
test.c:7:18: warning: format specifies type 'unsigned int' but the argument has type 'long' [-Wformat]
printf("%u", -2147483649);
~~ ^~~~~~~~~~~
%ldd 와 i 는 printf 에서는 기본적으로 같으나, scanf에서 역할이 다름d : 10진수 입력받음i : 10/8/16진수 입력 받음%uunsigned int → int (4바이트)test.c:7:18: warning: format specifies type 'unsigned int' but the argument has type 'long' [-Wformat]
printf("%u", 2147483648); // int 범위 +1
~~ ^~~~~~~~~~
%ldlong long으로 넘겨 받음printf("%u", -1); // 4294967295 (unsigned int 범위에서 언더플로우)%x %Xunsigned int → int (4바이트)test.c:7:18: warning: format specifies type 'unsigned int' but the argument has type 'long' [-Wformat]
printf("%x", 2147483648);
~~ ^~~~~~~~~~
%lx%%'%' 출력
이걸 하루만에 할 수 있을까요!? 우쒸...