/*
This is the FUN!!! way of generating
random words from list. Keep in mind this
was supposed to be stupid and I am quite
aware it isn't anywhere close to the best
way to do it!
Just havin' fun :p
LogicKills
*/
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <ctime>
using namespace std;
int words = 0;
int randomNumber;
vector<string> file;
string line;
void LOAD_FILE(){
file.clear();
ifstream infile ("words.txt", std::ios_base::in);
while (infile >> line)
{
file.push_back (line);
++words;
}
}
int GIMMEH_RANDOM(){
srand((unsigned int)time(0));
const int generated = (rand() % words);
return (generated);
}
int main ()
{
LOAD_FILE();
randomNumber = GIMMEH_RANDOM();
cout << "Random generated word is: " << file[randomNumber] << endl;
cin.get();
return 0;
}
[C++]WordGen (lol)
Started by LogicKills, Dec 18 2008 11:28 PM
7 replies to this topic
#1
Posted 18 December 2008 - 11:28 PM
http://logickills.org
Science - Math - Hacking - Tech
Science - Math - Hacking - Tech
|
|
|
#2
Posted 25 December 2008 - 11:37 AM
#3
Posted 25 December 2008 - 11:33 PM
Turk4n said:
OMG SO funn...no just no. I couldn't find the fun. But great job in making it :)
The fun I guess came with me giving it to someone as a nudge into how to do it..
I wish I had logged the convo on AIM..
http://logickills.org
Science - Math - Hacking - Tech
Science - Math - Hacking - Tech
#4
Posted 26 December 2008 - 12:34 AM
LogicKills said:
The fun I guess came with me giving it to someone as a nudge into how to do it..
I wish I had logged the convo on AIM..
I wish I had logged the convo on AIM..
Cool, well still GJ with it :)
#5
Guest_Jordan_*
Posted 26 December 2008 - 06:46 AM
Guest_Jordan_*
I would guess the fun part was writing the code.
#6
Posted 26 December 2008 - 08:34 AM
Jordan said:
I would guess the fun part was writing the code.
Oh, I feel that too when making something new :)
#7
Posted 26 December 2008 - 09:25 AM
Hm that's interesting! Nice job. :D Have you ever done something like making all possible sentence with words in a file? That would be interesting also. :)
#8
Posted 26 December 2008 - 02:09 PM
chili5 said:
Hm that's interesting! Nice job. :D Have you ever done something like making all possible sentence with words in a file? That would be interesting also. :)
I might try out that later in java :>


Sign In
Create Account


Back to top









