C++//将1D字符数组转换为大写
C++ // Converting a 1D array of chars to uppercase
我需要修改一个字符的1D数组,并将该数组中包含的所有字母放入大写字母中,然后打印出来(并用大写字母保存数组)。
这就是我的功能,但我不确定我还必须做什么才能让正常工作
void putInUppercase(char text[]) {
assert(isValidText(text));
int index(0);
while (text[index] != EOT)
putchar(toupper(text));
cout << text[index];
++index;
}
text是包含字符的数组。
听起来像是你想要的:
text[index]=toupper(text[index]);
而不是
否则,您将尝试写入两次输出,并且永远不会更新数组
此外,while循环似乎缺少括号。
void putInUppercase(char text[]) {
assert(isValidText(text));
int index(0);
while (text[index] != EOT)
}
text[index]=toupper(text[index]);
cout << text[index];
++index;
}
}
相关文章:
- HEX值到wchar_t字符(UTF-8)的转换
- 将Integer转换为4字节的unsined字符矢量(按大端字节顺序)
- 将字符指针十六进制转换为字符串并保存在文本文件C++中
- 从矢量<无符号字符>转换为字符* 包括垃圾数据
- 如何将一个ostringstream十六进制字符串字符对转换为单个unit8t等价的二进制值
- 转换特殊字符(UTF-8)
- 将转换字符键入 int 以用作向量C++的索引
- 将字符随机转换为大写的函数
- 尝试将字符串/字符转换为整数会产生意外结果
- 如何在保持其值的同时将 c++ 无符号字符变量转换为 char 变量
- 转换字符时Arduino DUE 和 Arduino UNO 之间的区别
- 如何在C++中正确重载运算符转换字符*?
- 如何转换数据结构以在 c++ 中转换字符*
- 不兼容的转换字符
- 将转换字符数组[16]键入为int 128位
- 在c++中转换字符编码
- 使用递归转换字符
- 如何在Objective-C/C/C++中转换字符和字节的位置
- C++到Pep/8汇编语言的转换——字符数组
- 转换字符>十六进制