Ok. I am writing a program that tells your fortune.
What it does is a random number generator makes a number, then from a data file full of fortunes, it picks the line corresponding with the number. What I can't get it to do is to tell the function for reading the file (ReadFile) what the random number is.
Here is my code:
fyi: I'm programming this in textbased telnet linux.
#include <iostream.h>
#include <fstream.h>
#include <time.h>
#include "home/ampalfe/APClasses/apstring.h"
// Global Constants
const int NUM = 0;
// Function Prototypes
int Numbergenerator();
apstring ReadFile ( NUM );
int main()
{
cout<<" ----The Super Fortune Teller----"<<endl<<endl;
cout<<" warning: all fortunes generated that come true are purely
coincidental and do not reflect the ability of our staff
or this generator."<< endl;
cout<<" Now.... To recieve your fortune<<endl<<endl<<endl<<endl;
cout<< "This is your fortune.........."<<endl;
Numbergenerator();
ReadFile( NUM );
}
int Numbergenerator()
{
srand ( unsigned (time(0)));
NUM = rand()%2;
return NUM;
}
apstring ReadFile(NUM)
{
ifstream inFile("/home/ampalfe/Game/Fortunes.stuff");
getline( inFile, NUM);
return apstring;
}
any help would be apreciated. Thanks
ampalfe
edit:: oops, I forgot to tell you how the data file is set up.....
it's
1 You will eat a lot today
2 You will be attracted to a co worker today
3 don't go outside, the weather is bad
etc.
Thanks again