#include <iostream>
#include <algorithm>

using namespace std;

int main(void)
{
	string cities1[] = { "Jeju", "Pangyo", "Seoul", "NewYork", "LA", "Jeju", "Pangyo", "Seoul", "NewYork", "LA" };

	int length = sizeof(cities1) / sizeof(string);

	for (int i = 0; i < length;i++)
		transform(cities1[i].begin(), cities1[i].end(), cities1[i].begin(), tolower);


	for (int i = 0; i < length;i++)
		cout << cities1[i] << endl;

	return 0;
}

 

 - algorithm의 transform()를 이용.

1. #include <algorithm> 추가

2. using namespace std; 추가

3. transform(문자열.begin(), 문자열.end(), 문자열.begin(), tolower);

 문자열 값이 소문자로 변경되어 해당 문자열에 입력된다.

 

#include <iostream>
#include <algorithm>

using namespace std;

int main(void)
{
	string cities1[] = { "Jeju", "Pangyo", "Seoul", "NewYork", "LA", "Jeju", "Pangyo", "Seoul", "NewYork", "LA" };

	int length = sizeof(cities1) / sizeof(string);

	for (int i = 0; i < length;i++)
		transform(cities1[i].begin(), cities1[i].end(), cities1[i].begin(), toupper);


	return 0;
}

 - algorithm의 transform()를 이용.

1. #include <algorithm> 추가

2. using namespace std; 추가

 - transform(문자열.begin(), 문자열.end(), 문자열.begin(), toupper);

 문자열 값이 대문자로 변경되어 해당 문자열에 입력된다.

 

 

 

#include <string>
using namespce std;
int main(void)
{
	string s="A";
    char lower = tolower(s);
    
    char upper = toupper(lower);
    
    return 0;
}

 

'Programming 언어 > C++' 카테고리의 다른 글

[C++] 정수 두 범위가 겹치는 지 확인  (0) 2020.11.25
[C++] 배열 최대값 구하기  (0) 2020.11.25
[C++] string 배열 수 세기  (0) 2020.11.25

+ Recent posts