diff options
author | EliteTK <tomasz.kramkowski@gmail.com> | 2014-02-24 21:03:53 +0000 |
---|---|---|
committer | EliteTK <tomasz.kramkowski@gmail.com> | 2014-02-24 21:03:53 +0000 |
commit | be9d9aedb53e9b3211765f16bf4b90f5d31c1722 (patch) | |
tree | f9368e8a880abf9b9392d631da1e5a373c23dc7e /randomcase.c | |
parent | de4075f451a2d6e457dbf9dff714d166618c4495 (diff) | |
download | c-stuff-be9d9aedb53e9b3211765f16bf4b90f5d31c1722.tar.gz c-stuff-be9d9aedb53e9b3211765f16bf4b90f5d31c1722.tar.xz c-stuff-be9d9aedb53e9b3211765f16bf4b90f5d31c1722.zip |
Added all files
Diffstat (limited to 'randomcase.c')
-rw-r--r-- | randomcase.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/randomcase.c b/randomcase.c new file mode 100644 index 0000000..c587d1a --- /dev/null +++ b/randomcase.c @@ -0,0 +1,44 @@ +#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); +} |