Created
June 7, 2015 11:21
-
-
Save rumidier/061109c20c665e7142bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 키보드로 문자열을 입력 (길이 20미만) 받아서 역순으로 출력하시오 | |
*/ | |
#include <stdio.h> | |
#define MaxLen 20 | |
int | |
main () | |
{ | |
char str[MaxLen]; | |
int i, no; | |
gets(str); | |
no=0; | |
while (str[no] != '\0') no++; | |
printf("[%d]\n", no); | |
for (i=no - 1; i>=0; i--) { | |
//printf("[%c]", str[i]); | |
printf("%c", str[i]); | |
} | |
printf("\n"); | |
return 0; | |
} | |
/* | |
* gets() 함수로 문장 입력시 '\0' 기준으로 입력이 됩니다. | |
* 저장된 배열 검사시 str 끝 문자열을 검색해 길이를 구한후 | |
* 길이의 마지막 값부터 출력합니다. | |
* 하고 보니 한글은 3byte 로 인식해서 한글은 이방법으로 안됨 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment