- Padgom's Tistory!
post list
2015년 1월 12일 월요일
2014년 5월 12일 월요일
NSInteger형을 사용해서 printf와 scanf함수 사용하기
Cocoa 환경은 NSInteger형을 도입해서 32비트 에서는 int형 64비트 모델에서는 long 형이 되도록 정의 했습니다.
방법 1) printf만쓸때
NSInteger n= ....;
printf("Input=%ld \n", (long)n);
방법2)
a 처럼 매크로를 작성해두고 b 처럼 사용을 하시면 됩니다.
a. 매크로정의
==========================
#if __LP64__
#define FMTd "ld"
#else
#define FMTd "d"
#endif
==========================
b. 매크로 사용
=============================
NSInteger n;
scanf("&" FMTd, &n);
printf("Input=% " FMTd "\n", n);
=============================
피드 구독하기:
글 (Atom)