aboutsummaryrefslogtreecommitdiffstats
path: root/randomcase.c
blob: 00b9d308867ce009ebfa7729164562e21110d6b1 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 * String letter case randomiser.
 *
 * Copyright (C) 2014  Tomasz Kramkowski <tk@the-tk.com>
 *
 * This program is free software. It is licensed under version 3 of the
 * GNU General Public License.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see [http://www.gnu.org/licenses/].
 */

#include <stdlib.h>
#include <stdio.h>
#include <time.h>


#define MAXLINE 1000

void upper (char string[], int position) {
	
	if (string[position] < 'z' && string[position] > 'a' ) {
		string[position] -= 'a';
		string[position] += 'A';
	}
}

void lower (char string[], int position) {
	
	if (string[position] < 'Z' && string[position] > 'A' ) {
		string[position] -= 'A';
		string[position] += 'a';
	}
}



int main (int argc, char **argv) {
	srand(time(NULL));
	
	char input_string[MAXLINE];
	char c;
	int i = 0;

	while ((c = getchar()) != '\0') {
		input_string[i++] = c;
	}
	
	input_string[i] = '\0';	
	
	for (i = 0; i < MAXLINE; i++) {
		(rand() & 1) ? upper(input_string, i) : lower(input_string, i);
	}
	
	printf("Output: %s \n", input_string);
}