递增指针数组 [英] incrementing array of pointers
本文介绍了递增指针数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
int main()
{
students *s;
int num=0;
s=new students[num];
char c;
char stream[10],name[50];
int year;
double rollno;
do
{
cout<<"enter the stream";
cin>>stream;
cout<<"enter the year of joining the college"<<endl;
cin>>year;
cout<<"enter your name";
cin>>name;
cout<<"enter your rollno";
cin>>rollno;
num++;
cout<<"do you want to continue (y/n)";
cin>>c;
}while(c!='n');
cout<<num;
return 0;
}
代码执行后我想获得num的值,但它没有显示任何内容
为什么?
错误是一个断点,表示无法读取位置'位置'访问不违反
thnx
after the code gets executed i want to get the value of "num" but it is showing nothing
why?
the error is a breakpoint which says "unable to read the location 'location' access not violation"
thnx
推荐答案
你没有解释你想要实现什么,但请注意你不要在循环中迭代任何东西。您只增加变量num
,但它不会影响其他任何内容。您甚至不初始化数组变量,也从不索引它们。整个代码似乎没有任何意义。
-SA
You did not explain what did you want to achieve, but note that you don't iterate anything in your loop. You only increment the variablenum
, but it does not affect anything else. You don't even initialize array variables and never index them. The whole code does not seem to make any sense.
—SA
这篇关于递增指针数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文