C
(C언어) strcpy 사용방법
SAFE
2016. 4. 28. 16:51
아래 코드는 실행이 안되는 코드.
주석처리를 지우고 해도 안된다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #include<stdio.h> int main(void){ int a; //? char b[5]; printf("숫자 입력 : "); scanf("%d", &a); b=a%2==0?"짝수":"홀수"; printf("%s",b); return 0; } | cs |
strcpy를 사용하면 된다.
<오른쪽값을 왼쪽에 넣음>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #include<stdio.h> #include<stdlib.h> #include<string.h> int main(void){ int a=10; char answer[10]; strcpy(answer,a>10?"참":"거짓"); printf("%s", answer); return 0; } | cs |
출처 : http://itng.tistory.com/137