Array Questions and infile question

for a project I am working on I need to use infiles.

Is there a way to put 5 infiles into an array...and have them selected randomly

once the infile is selected how do i only pull certain lines?
yes fstream but

allow me to elaborate more as to what I am attempting to do

I am trying to make an animal guessing game, i have already made the .txt files for the animals i have chosen to use, I want to use these files in an array to randomly select which one is used. from there i will need to pull certain lines for the hints.
Ahhh, well instead of randomly pulling from the file, pull all of the data(if it's small of course) and put it into a vector, then randomly select from the vector.

If you're stuck on reading specific lines in the file, you'll probably have to parse out the \n || \r to get to a specific line, you can also seek to specific positions in the file.
i am not going to lie this is for a class and we have not gone over vectors....i am c/p one of the hint files

bird

hint 1 : I can be very colorful

hint 2 : I like to see my self in a mirror

hint 3 : I sometimes and louder then people like

hint 4 : in homes i live in a cage

hint 5 : people put a blanket over my cage when they want me to sleep


the file name is bird.txt the animal name is at the top for the check.....i honestly have no idea how to do this, i am not looking to pic a random hint but a random file. i have 5 files (bird,dog,cat,fish,snake) they are all .txt files, i am sorry i cannot be of more help to getting assistance on this, but i have tried to google this for a couple hours
for those trying to help me, without the .txt files this is what i have

#include <iostream>
using namespace std;

int main()
{
int guess;
int count;
array "filename" [5];// need to figure out how to array the file names
cout << "welcome to my animal guessing game" <<endl;
cout << " I will select an animal, and give you hints" <<endl;
cout << " and you will try to guess what it is" <<endl;
//that is the intro

//get hint one
count==0;
cout << " your first hint is : "<< endl;//need to get hint from file
cin >> guess;
//check if guess is = animal Animal ANIMAL
if animal is == animal then
if animal is not = animal then count++1
cout <<" congratulations you are correct!"<<endl;
cout <<" it took you" <count> " number of tries" cout << "sorry you are incorrect" <<endl;
cout << "your second hint is: " <<endl; //need to get hint from file.
cin >> guess;
if guess ==animal then
cout << "congratulations you are correct" <<endl;
cout <<"it took you" <count> "number of tries." endl;
if animal is not == then count ++1
cout <<"sorry you are incorrect," endl;
cout << "your third hint is: "<<endl; //need to get hint from file
cin >> guess;
if guess ==animal then
cout << "congratulations you are correct" <<endl;
cout <<"it took you" <count> "number of tries." endl;
if animal is not == then count ++1
cout <<"sorry you are incorrect," <<endl;
cout << "your fourth hint is: "<<endl; //need to get hint from file
cin >> guess;
if guess ==animal then
cout << "congratulations you are correct" <<endl;
cout <<"it took you" <count> "number of tries." <<endl;
if animal is not == then count ++1
cout <<"sorry you are incorrect," <<endl;
cout << "your fifth hint is: "<<endl; //need to get hint from file
cin >> guess
if guess== animal then
cout <<"congratulations you are correct" <<endl;
if guess is not == then
cout <<" I am sorry you are incorrt it was "<animal>" "<<endl;
cout <<"would you like to play again?" endl;

Topic archived. No new replies allowed.