接收“hi i is man”等消息并将其转换为大写“HI I AM MAN”的代码。
dangerouslySetInnerHTML
答案 0 :(得分:0)
对大写和小写使用toupper和tolower函数
#include <iostream> // std::cout
#include <string> // std::string
#include <locale> // std::locale, std::toupper
int main (){
std::locale loc;
std::string str="Test String.\n";
for (std::string::size_type i=0; i<str.length(); ++i)
std::cout << std::toupper(str[i],loc);
return 0;
}
答案 1 :(得分:0)
#include <stdio.h>
#include <ctype.h>
n = read(newsockfd, buffer, 255);
for(int i = 0; i < n; i++)
buffer[i] = toupper(buffer[i]);
printf("Here is the message: %s\n", buffer);