Ok, I have this working perfectly now, and I've edited this post and code below to reflect the updated correctly working code.
Read 50 words from a text file into an array of strings
The program will use random numbers for:
a.- It will generate a random number between 2 and 7 for the selection of the words to be used in the sentence
b.- It will generate a random number for the selection of the words. The number will be between 0 and 49, because those are the positions of the words in the array
It will display the sentence on the screen.
Thank you ahead of time for any suggestions
#include <string>
#include <iostream>
#include <fstream>
#include <time.h>
#include <stdlib.h>
#include <array>
using namespace std;
int main() {
ofstream outFile;
ifstream inFile;
const int size = 50; //initiate constant size for array
string word[size]; //initialize array of string
srand(time(0)); //sets timing factor for random variables
int Random2 = rand() % 6 + 2; //determines random value beteen 2 and 7
inFile.open("words.txt"); //opens input text file
if (!inFile.is_open()) { //tests to see if file opened corrected
exit(EXIT_FAILURE);
}
while (!inFile.eof()) { //Puts file info into string
for (int i = 0; i < size; ++i)
inFile >> word[i];
}
for (int i = 0; i < Random2; i++) { //loops through array and generates second random variable each loop to determine word to print
int Random1 = rand() % size;
cout << word[Random1] << " ";
}
cin.get();
}