ในบทช่วยสอนนี้ เราจะพูดถึงโปรแกรมเพื่อทำความเข้าใจการแปลงสตริงทั้งหมดเป็นตัวพิมพ์ใหญ่หรือตัวพิมพ์เล็กโดยใช้ STL ใน C++
ในการดำเนินการแปลงนี้ C++ STL มีฟังก์ชัน toupper() และ tolower() เพื่อแปลงเป็นตัวพิมพ์ใหญ่และตัวพิมพ์เล็กตามลำดับ
ตัวอย่าง
#include<bits/stdc++.h>
using namespace std;
int main(){
string su = "Tutorials point";
transform(su.begin(), su.end(), su.begin(), ::toupper);
cout << su << endl;
string sl = "Tutorials Point";
transform(sl.begin(), sl.end(), sl.begin(), ::tolower);
cout << sl << endl;
return 0;
} ผลลัพธ์
TUTORIALS POINT tutorials point