헉!!/Objective C
[Objective-C] 콘솔창에 변수출력
권태성
2011. 7. 17. 21:12
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// insert code here...
int sum;
sum = 10 + 25;
NSLog(@"%d", sum);
[pool drain];
return 0;
}
────────────────────────────────────────────────────────
대충 보면 알겠지만 C언어의 그것과 비슷합니다.
위 프로그램은 아주 간단한 예제로 sum이라는 변수를 선언하고 그 변수에 10+25의 값을 넣고 화면에 출력하는 예제입니다.
C 언어로 한다면
#include <stdio.h>
int main()
{
int sum;
sum = 10 + 25;
printf("%d", sum);
return 0;
}
이런 형식이 되려나요.
728x90