-Can anyone give an example of a program that fills an array with words or names?
and if anyone can use the AP class subsets that would be great. thanks
Printable View
-Can anyone give an example of a program that fills an array with words or names?
and if anyone can use the AP class subsets that would be great. thanks
I'm not to sure about what you are asking, but I'll give it a shot.
#include<apstring.h>
#include<apvecor.h>
void main ()
{
apvector<apstring>array (4,0);
array[3]="three";
array[2]="string";
}
Something like that? Or do you mean make up it's own words?
using apstring it would look something like this...
your #includes up here...
const int MAX_SIZE = 10; // the max # of apstrings in the array
typedef apstring Array_Name[MAX_SIZE]; // the array Array_Name here
int main()
{
// loop to fill each string in the array
for (int x=0; x<MAX_SIZE; x++)
Array_Name[x] = "something"; // fills each string in the array with "something"
return 0;
} // main
I think thats what you were asking. If not, oh well. If you wanted to ask the user what they would like to put in the array just throw in some cout/cin lines inside the loop.