From 379a273ffec1fefe8b6f9af3a959ae85eba17857 Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Sat, 3 Jan 2015 11:43:34 +0100 Subject: [PATCH] Add some simple samples for screenshots and similar stuff --- samples/crypt/main.c | 21 +++++++++++++++++++++ samples/simple/main.c | 10 ++++++++++ 2 files changed, 31 insertions(+) create mode 100644 samples/crypt/main.c create mode 100644 samples/simple/main.c diff --git a/samples/crypt/main.c b/samples/crypt/main.c new file mode 100644 index 0000000..773f0ea --- /dev/null +++ b/samples/crypt/main.c @@ -0,0 +1,21 @@ +#define _GNU_SOURCE +#include +#include +#include + +int check(char * str) { + /* Ich bin der größte! */ + static const char * correct = "TOgP5hrln1SAE"; + printf("%s\n", crypt(str, "TOPSECRET")); + return ! strcmp(correct, crypt(str, "TOPSECRET")); +} + +int main() { + char password[255]; + printf("Password: "); + scanf("%s", password); + if (check(password)) + printf("Success!\n"); + else + printf("Failure!\n"); +} diff --git a/samples/simple/main.c b/samples/simple/main.c new file mode 100644 index 0000000..0664bf0 --- /dev/null +++ b/samples/simple/main.c @@ -0,0 +1,10 @@ +#include +#include + +int main(int argc, char ** argv) { + int count = atoi(argv[1]); + + while (count --> 0) { + printf(argv[2]); + } +} -- 2.39.5