Make a windows app. + random number prob

Okay so I'm making a variant on the game called 30 seconds, but the only thing the program I'm making needs to do is pick 5 random words and display them, it's doing that but something is wrong.. It always picks 5 words from 1 of the lists I make, while it should randomly pick words from the list.. you'll see what I mean in the program, try making 4 .txt files filled with the same stuff, you'll see every 'round' it'll give you items from the same list..

the code is 'a bit choatic' but that's because I've made a million changes but couldn't get it to pick a random list..

Second thing, I'd like to make this a VERY BASIC windows app.. currently it's just a console app (made in visual studio) but I'd just like one window with 5 labels and a button that kinda does the same thing, I tried it but when I'm doing every ting wrong xD
I code in the .cpp file when making the windows app but then I have to code in the .m part to change the .onclick handler for the button, but then it doesn't find my vector with the words in..

Help : )

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
// 30Sseconds.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "time.h"
#include <vector>
#include <string>
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <ctime> 
#include <limits>
#include <dos.h>
#include <stdio.h>
#include <conio.h>

using namespace std;

vector<string> persoon;
vector<string> ding;
vector<string> citaat;
vector<string> plaats;


void persoonF(){
	string line;
	ifstream myfile ("persoon.txt");
	if (myfile.is_open())
	{
		while ( myfile.good() )
		{
			getline (myfile,line);
			persoon.push_back(line);
		}
		myfile.close();
	}
}
void plaatsF(){
	string line;
	ifstream myfile ("plaats.txt");
	if (myfile.is_open())
	{
		while ( myfile.good() )
		{
			getline (myfile,line);
			plaats.push_back(line);
		}
		myfile.close();
	}
}
void citaatF(){
	string line;
	ifstream myfile ("citaat.txt");
	if (myfile.is_open())
	{
		while ( myfile.good() )
		{
			getline (myfile,line);
			citaat.push_back(line);
		}
		myfile.close();
	}
}
void dingF(){
	string line;
	ifstream myfile ("ding.txt");
	if (myfile.is_open())
	{
		while ( myfile.good() )
		{
			getline (myfile,line);
			ding.push_back(line);
		}
		myfile.close();
	}
}

string willekeurig(int will)
{
	string a;
	while(a.size() == 0){
		if(will <3)
		{if(persoon.size() != 0)
		{
			
			int random_integer = rand()%persoon.size();

			
			a = persoon[random_integer];
			persoon.erase (persoon.begin()+random_integer);
		}}
		if(will < 6 && will>=3)
		{
			if(ding.size() != 0)
			{
				int random_integer = rand()%ding.size();
				a = ding[random_integer];
				ding.erase (ding.begin()+random_integer);
			}
		}
		if(will<8 && will>=6)
		{
			if(citaat.size() != 0)
			{
				int random_integer = rand()%citaat.size();		
				a = citaat[random_integer];
				citaat.erase (citaat.begin()+random_integer);
			}
		}
		if(will < 10 && will >=8)
		{
			if(plaats.size() != 0)
			{
				int random_integer = rand()%plaats.size();
				a = plaats[random_integer];
				plaats.erase (plaats.begin()+random_integer);
			}
		}
	}
	return a;
}

void woord(){
		srand(time(NULL));
		int	will2 = rand() % 10;
		cout << "\n " << willekeurig(will2);
}

void Delay(float milliSeconds)
{
const float clk_strt = float(clock());
 
while( clock() - clk_strt < milliSeconds )
continue;
}

int _tmain(int argc, _TCHAR* argv[])
{
	persoonF();
	plaatsF();
	citaatF();
	dingF();

	
	srand(time(0));
	int will, will1, will2, will3, will4, will5, will6;
	while(true){
	
		cout << "\n >>>>>>>Druk op een knop om door te gaan<<<<<<<";
		cin.ignore(std::numeric_limits<streamsize>::max(),'\n');

		woord();
		Delay(50);
		woord();
		Delay(50);		
		woord();
		Delay(50);
		woord();
		Delay(50);		
		woord();
		

	}

	return 0;
}
I don't understand what this functions are for ???
persoonF();
plaatsF();
citaatF();
dingF();

They don't change anything,they don't return anything.
They only change a local variable <line>.
I don't read your code attentive,but i think that you must declare a <line > as global variable.
Ofcourse they do a lot..

persoon
plaats
citaat
ding

are vectors and those functions fill the vectors with the words that are stocked in

persoon.txt
plaats.txt
citaat.txt
ding.txt
Oh sorry
Topic archived. No new replies allowed.