64,632
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
using namespace std;
class small
{
private:
int m;
char str[110];
public:
small(int k) { m = k; };
~small() { };
void input()
{
for (int i = 0; i < m; i++) cin >> str[i];
}
void convert()
{
for (int i = 0; i < m; i++) str[i] = str[i] - 32;
}
void output()
{
for (int i = 0; i < m; i++) cout << str[i];
}
};
int main()
{
int m;
cin >> m;
small s(m);
s.input();
s.convert();
s.output();
cout << endl;
system("pause");
return 0;
}
写的乱七八糟,不知所云
楼主,不知道你想干嘛?(小写字母变大写?)
C++主要是面向对象,没看见你用类啊!
m,全局变量,在一个函数内部读取?
str[m]怎么看怎么不顺眼,不像数组赋值。
字符数组如果没有输入是没有'\0'的。
数组范围str[0]到str[m-1],没有str[m]!
n都没赋值,你就用得劲加劲的。