Home / utk / cs102 / fa16 / labe / code_snippets / function_example.cpp
Directory Listing
function_example.cpp
randchar_example.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <cstdlib>
#include <string>
#include <ctime>

using namespace std;

const int NAME_SIZE = 10;
const string names[] = { "Clara", "Plank", "Vanderzanden", "Gregor", "Caleb", "Maguire", "Sharon", "Kirsten", "Jacob", "Harambe" };

void name_generate();

int main() {
	srand(time(NULL));
	for (int i = 0; i < 8; i++)
		name_generate();
	cout << endl;
}

void name_generate() {
	cout << names[rand() % NAME_SIZE] << endl;
}