삼항연산자
(조건문)?(참):(거짓);
ex)
#include<stdio.h>
#include<string.h>
int main(int argc, char *argv[])
{
int count =0;
if(strcmp(argv[1],"1")==0)
count =1;
else
count =0;
(count==0)?printf("HI\n"):printf("count=1\n");
return 0;
}
다만 평소처럼 쓰는 이항연산자와 삼항연산자의 성능차이는 미미하다고 함.
'Programming > C' 카테고리의 다른 글
열거형 enum (0) | 2012.07.09 |
---|---|
sscanf , sprintf (0) | 2012.07.06 |
문자열 붙이기 Strcat() (0) | 2012.07.04 |
Strtok 문자열 자르기 (0) | 2012.06.29 |
Extern 함수 (0) | 2012.05.21 |