hi every body,
i need some help please i don't know why i cannot print my elements in my arrays.
i don't know why?
i have a struct Word whith 2 element one is a string and the other is integer.
i m read my data with void readData (), at the same times i m storing them into a array but i m having a problem to print my wordsarray.i know that i m missing some thing please some help to see this a bit more clear
#include<iostream>
#include<string>
#include<iomanip>
usingnamespace std;
struct Word
{
string words;
int amounts;
};
void readData(Word wordsarray[], int& size);
int main () {
int max = 100;
int size = 0;
Word wordsarray [max];
int j= 0;
while(j > max)
{
cout<< wordsarray[j].words<< endl;
++j;
}
readData( wordsarray,size );
}
void readData(Word wordsarray[], int& size)
{
Word temp;
cout << "enter a word"<< endl;
while(temp.words != "#")
{
cin >> temp.words;
if(wordsarray[size].words.find(temp.words))// check if there is the given
//word in the arrau
{
++wordsarray[size].amounts;
}
wordsarray[size]= temp;// if there is not we stored the given word
++size;
}
}