blob: 9b63431c486e1561c7935edab7219310e7dbab6b (
plain)
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
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "modes.h"
#include "words.c"
int word_mode(int length, bool newline, bool capitalize) {
for (int i = 0; i < length; i++) {
int index = rand() % WORDS_COUNT;
char word[1024];
strncpy(word, words[index], 1024);
if (i == 0 && capitalize) word[0] += 'A' - 'a';
if (i == length - 1) printf("%s", word);
else printf("%s ", word);
}
if (newline) printf("\n");
return 0;
}
int sentence_mode(int length, bool newline) {
for (int i = 0; i < length; i++) {
int size = 10 + rand() % 20;
word_mode(size, false, true);
printf(". ");
if (newline) printf("\n");
}
return 0;
}
int paragraph_mode(int length, bool newline) {
for (int i = 0; i < length; i++) {
int size = 6 + rand() % 10;
sentence_mode(size, false);
if (newline) printf("\n\n");
}
return 0;
}
|