*message.txt
*I'm able to read each word from a file with
*Then I'm trying to put each word into
*Problem is each value in
words has the memory address of
word, thus every value in
words becomes the last value that
word was changed to. For example, the output at the end of
words at the end of the program would be
*What I want is this...
*This is the code I wrote to append text from file to
word into
words
1 2 3 4 5 6 7 8 9 10 11 12 13
|
int main(){
ifstream inFile;
int size = 9;
char *words[size];
char word[10];
inFile.open("message.txt");
while(inFile >> word){
static int count = 0;
words[count++] = word;
}
}
|
Please show me how to correct it!
NOTE:
*Please do not provide me with solutions utilizing the string, vector, or any other classes like them.