please I need help apace
thanks for every one can help me
How can I use list array with no pointer in c++ programming?
u have to ponit it or use
these are the 2 way's:
#include %26lt;iostream%26gt;
using namespcae std;
int main()
{
int num[8];
int index;
num[0] = 42;
num[1] = 2001;
num[2] = 7;
num[3] = 180;
num[4] = 99;
num[5] = 1993;
for(index = 0; index %26lt;= 5; index++)
{
std::cout%26lt;%26lt; index[num] %26lt;%26lt; endl;
}
system("pause");
return 0;
}
or
#include %26lt;iostream%26gt;
#define MAX 20
using namespcae std;
int main()
{
int a[MAX] = {23,43,4,5,34,343,12,14};
int b;
cout.setf(ios::right);
for(b = 0; b %26lt; MAX; b++){
cout %26lt;%26lt; endl %26lt;%26lt; endl;
cout %26lt;%26lt; "The Elemnt in ";
cout.width(2);
cout %26lt;%26lt; (b +1) %26lt;%26lt; " is ";
cout.width(2);
std::cout %26lt;%26lt; b[a];
}
return 0;
}
Reply:I dont quite understand the question either. But from what I think your asking...
1) Declare the array
datatype arrayname[listSize];
example
int array1[16]
2) Fill the array with values
either use a for loop, or manually assign values.
Reply:It wouldn't be a list anymore since everything you'll store in it will be static allocated... I don't quite understand your question.
Reply:use the vector class
#include %26lt;vector%26gt;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment