From 15b875139082a33729dcab59b96a1842d59d6fc3 Mon Sep 17 00:00:00 2001 From: pommicket Date: Sun, 31 Jan 2016 16:39:36 -0500 Subject: Created NameGeneratorEvolve --- build/GNULinux/NameLearn | Bin 0 -> 9744 bytes build/GNULinux/StringCreate | Bin 0 -> 16992 bytes build/GNULinux/StringLearn | Bin 0 -> 16464 bytes src/FileIO.h | 36 ++++++++++++++++++++++++++++++++++++ src/Makefile | 6 ++++++ src/main.c | 33 +++++++++++++++++++++++++++++++++ 6 files changed, 75 insertions(+) create mode 100755 build/GNULinux/NameLearn create mode 100755 build/GNULinux/StringCreate create mode 100755 build/GNULinux/StringLearn create mode 100644 src/FileIO.h create mode 100644 src/Makefile create mode 100644 src/main.c diff --git a/build/GNULinux/NameLearn b/build/GNULinux/NameLearn new file mode 100755 index 0000000..05c98c3 Binary files /dev/null and b/build/GNULinux/NameLearn differ diff --git a/build/GNULinux/StringCreate b/build/GNULinux/StringCreate new file mode 100755 index 0000000..6557221 Binary files /dev/null and b/build/GNULinux/StringCreate differ diff --git a/build/GNULinux/StringLearn b/build/GNULinux/StringLearn new file mode 100755 index 0000000..b2d104d Binary files /dev/null and b/build/GNULinux/StringLearn differ diff --git a/src/FileIO.h b/src/FileIO.h new file mode 100644 index 0000000..a6da86b --- /dev/null +++ b/src/FileIO.h @@ -0,0 +1,36 @@ +int fileSize(FILE* fp) +{ + //Size of file in bytes + int sz; + fseek(fp, 0L, SEEK_END); + sz = ftell(fp); + fseek(fp, 0L, SEEK_SET); + return sz; +} + + +char* fileContents(char* fname) +{ + //Contents of a file + FILE* fp = fopen(fname, "r"); + int sz = fileSize(fp); + char* buffer = malloc(sz); + fread(buffer, sz, 1, fp); + fclose(fp); + return buffer; +} + + +int exists(char* filename) +{ + return access(filename, F_OK) != -1; +} + +void touch(char* filename) +{ + if (exists(filename)) + return; + FILE *fp; + fp = fopen(filename, "w"); + fclose(fp); +} diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..12989ee --- /dev/null +++ b/src/Makefile @@ -0,0 +1,6 @@ +CC=gcc + +default: NameLearn + +NameLearn: main.c + $(CC) -o NameLearn main.c diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..48c2bcd --- /dev/null +++ b/src/main.c @@ -0,0 +1,33 @@ +#include +#include +#include +#include +#include "FileIO.h" + +int main() +{ + int L; + printf("Enter minimum lengths of names: "); + scanf("%d", &L); + + touch("s.stl"); + char* cmd; + char* name; + char nameArray[2048]; + double R; + cmd = malloc(4096); + while (1) + { + + sprintf(cmd, "./StringCreate s.stl --stopX -l %d > name.txt", L); + system(cmd); + + name = fileContents("name.txt"); //Will include newline + printf("Rate the following name: %sRating [-1 to 1 or Ctrl-C to quit]: ", name); + name[strlen(name)-1] = 'X'; + scanf("%f", &R); + + sprintf(cmd, "./StringLearn %s -r %f -s s.stl", name, R); + system(cmd); + } +} -- cgit v1.2.3