哪位大佬能告诉我这是什么情况吗

幽药香 2017-12-30 06:53:21
...全文
572 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
MuTu° 2018-01-14
  • 打赏
  • 举报
回复
自定义函数只在定义时,声明函数返回值类型,而在调用时不再加返回值类型。但是在调用时,函数名字后,一定要带括号,即使实参为空,而且参数前也不再加如int,double等数据类型。
fuckguidao 2018-01-13
  • 打赏
  • 举报
回复
唉,楼上良心,把m改成i
biufuyf 2018-01-12
  • 打赏
  • 举报
回复
#include <iostream> using namespace std; int m; char str[110] = {0}; void input() { cin>>m; for(int i=0;i<m;i++) cin>>str[i]; } void output() { for(int i=0;i<m;i++) cout<<str[i]<<endl; } int main() { int n = 0; input(); while(str[n] != '\0') { str[n] = str[n]-32; n++; } output(); system("pause"); return 0; } 这是在你的代码基础上修改的,输入的个数不建议用全局变量,看着特别扭
谁学逆向工程 2018-01-05
  • 打赏
  • 举报
回复
input 函数的循环下标应该从0 开始,你后面最后一个下标越界了
gfxmode 2018-01-05
  • 打赏
  • 举报
回复
注意代码风格
赵4老师 2018-01-05
  • 打赏
  • 举报
回复
崩溃的时候在弹出的对话框按相应按钮进入调试,按Alt+7键查看Call Stack即“调用堆栈”里面从上到下列出的对应从里层到外层的函数调用历史。双击某一行可将光标定位到此次调用的源代码或汇编指令处,看不懂时双击下一行,直到能看懂为止
啊哈moment 2018-01-05
  • 打赏
  • 举报
回复
引用 5 楼 wyg300270 的回复:

#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;
}

m < 110
wyg300270 2018-01-04
  • 打赏
  • 举报
回复

#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;
}

wyg300270 2018-01-04
  • 打赏
  • 举报
回复
写的乱七八糟,不知所云 楼主,不知道你想干嘛?(小写字母变大写?) C++主要是面向对象,没看见你用类啊! m,全局变量,在一个函数内部读取? str[m]怎么看怎么不顺眼,不像数组赋值。 字符数组如果没有输入是没有'\0'的。 数组范围str[0]到str[m-1],没有str[m]! n都没赋值,你就用得劲加劲的。
陪妳看星星 2017-12-31
  • 打赏
  • 举报
回复
n没有赋初值
开心秋水 2017-12-31
  • 打赏
  • 举报
回复
调用函数时,不能加上函数返回值的类型,不然就变成了又声明一个同名的函数。
所以把main里面的input和output前面的void删除。
Sunjihang_123 2017-12-30
  • 打赏
  • 举报
回复
char型数组里面是没有‘\0’的 而string里面有, 解决办法:一、手动加'\0'; 二、使用string类型

64,282

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧