[C] 소문자는 대문자로 대문자는 소문자로

#include <stdio.h>
#include <string.h>
#include <ctype.h>

int UpperLower(char *temp);

int main()
{
	char strtest[10] = {0};

	strcpy(strtest, "aBcDeF!@#");
	printf("Orinal Str - %s\n\n", strtest);

	UpperLower(strtest);
	printf("UpperLower - %s\n\n", strtest); 

	return 0;
}

int UpperLower(char *temp)
{
	for( ; *temp != NULL; temp++)
	{
		if(isalpha(*temp))
		{
			*temp = *temp ^ 0x20;
		}
	}

	return 0;
}

댓글

이 블로그의 인기 게시물

WOL(Wake On Lan) 기능 사용

시간에 요일 표시