Name:
Anonymous
2010-05-06 13:08
int listsize, count;
cout<<"Define size of list: ";
cin>>listsize;
cout<<endl;
int list[listsize];
Are there any problems with this? It works fine but I just want to make sure I'm not committing a faux pas.
Name:
Anonymous
2010-05-06 13:17
int *list, listsize;
printf("Define size of list: ");
scanf("%d\n", &listsize);
list = malloc(listsize * sizeof(int));
Happy to help.
Name:
Anonymous
2010-05-06 16:10
>>11
What am I actually doing when I run this and give a higher number the second time then?
#include <iostream>
using namespace std;
int main()
{
int listsize, count;
cout<<"Define size of list: ";
cin>>listsize;
cout<<endl;
int list[listsize];
cout<<"Enter numbers: ";
for (count=0; count<listsize; count++) {
cin>>list[count];
}
for (count=0; count<listsize; count++) {
cout<<list[count]<<", ";
}
cin>>listsize;
cout<<"Enter numbers: ";
for (count=0; count<listsize; count++) {
cin>>list[count];
}
for (count=0; count<listsize; count++) {
cout<<list[count]<<", ";
}
return 0;
}