#include<iostream>
using namespace std;
#include<cstdlib>
#include<cstdio>
int main()
{
char a[] = { 'j','5','k'};
int b[] = { 1,2,30 };
cout << a << endl;
cout << b << endl;
int c;
cin >> c;
return 0;
//结果是这样,不理解,希望有大佬能解释一下,万分感谢
}
因为字符数组没加\0作为结束标志,所以后面有问号,输出b是数组的地址
改之后
#include<iostream>
using namespace std;
#include<cstdlib>
#include<cstdio>
int main()
{
char a[] = { 'j','5','k','\0'};
int b[] = { 1,2,30 };
cout << a << endl;
for (int i=0;i<3;i++)
cout << b[i] <<" ";
int c;
cin >> c;
return 0;
}
应该是你ide的问题。我在本机上跑没有问题
您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!