主题:数据结构串的问题
我今天刚看了串的内容,
写了个小程序,
想初始化2个串,编译通过了;
为什么运行到初始化第2个串的时候就提前出现print any key to continue???
#include <iostream>
using namespace std;
typedef struct {
char *ch;
int length;
}hstring;
int main()
{
int i,m,b;
hstring *str3;
cout<<"please enter the length of str3:\n";
cin>>m;
str3=new hstring[m];
str3->length=m;
for(i=0;i<m;i++)
cin>>str3->ch[i];
hstring *str4;
cout<<"please enter the length of str4:\n";
cin>>b;
str4=new hstring[b];
str4->length=b;
for(i=0;i<b;i++)
cin>>str4->ch[i];
return 0;
}
写了个小程序,
想初始化2个串,编译通过了;
为什么运行到初始化第2个串的时候就提前出现print any key to continue???
#include <iostream>
using namespace std;
typedef struct {
char *ch;
int length;
}hstring;
int main()
{
int i,m,b;
hstring *str3;
cout<<"please enter the length of str3:\n";
cin>>m;
str3=new hstring[m];
str3->length=m;
for(i=0;i<m;i++)
cin>>str3->ch[i];
hstring *str4;
cout<<"please enter the length of str4:\n";
cin>>b;
str4=new hstring[b];
str4->length=b;
for(i=0;i<b;i++)
cin>>str4->ch[i];
return 0;
}