Jump to content

[C++]WordGen (lol)

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
7 replies to this topic

#1
LogicKills

LogicKills

    Programmer

  • Members
  • PipPipPipPip
  • 139 posts
/*

           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;

}



http://logickills.org
Science - Math - Hacking - Tech

#2
Turk4n

Turk4n

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 3,847 posts
OMG SO funn...no just no. I couldn't find the fun. But great job in making it :)
Posted Image

#3
LogicKills

LogicKills

    Programmer

  • Members
  • PipPipPipPip
  • 139 posts

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

#4
Turk4n

Turk4n

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 3,847 posts

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..

Cool, well still GJ with it :)
Posted Image

#5
Guest_Jordan_*

Guest_Jordan_*
  • Guests
I would guess the fun part was writing the code.

#6
Turk4n

Turk4n

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 3,847 posts

Jordan said:

I would guess the fun part was writing the code.

Oh, I feel that too when making something new :)
Posted Image

#7
chili5

chili5

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 7,247 posts
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
Turk4n

Turk4n

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 3,847 posts

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 :>
Posted Image