summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpommicket <leonardomtenenbaum@gmail.com>2016-01-31 16:39:36 -0500
committerpommicket <leonardomtenenbaum@gmail.com>2016-01-31 16:39:36 -0500
commit15b875139082a33729dcab59b96a1842d59d6fc3 (patch)
treead8a3eaa8d3101913cbc8b231243fb96342eb572
Created NameGeneratorEvolve
-rwxr-xr-xbuild/GNULinux/NameLearnbin0 -> 9744 bytes
-rwxr-xr-xbuild/GNULinux/StringCreatebin0 -> 16992 bytes
-rwxr-xr-xbuild/GNULinux/StringLearnbin0 -> 16464 bytes
-rw-r--r--src/FileIO.h36
-rw-r--r--src/Makefile6
-rw-r--r--src/main.c33
6 files changed, 75 insertions, 0 deletions
diff --git a/build/GNULinux/NameLearn b/build/GNULinux/NameLearn
new file mode 100755
index 0000000..05c98c3
--- /dev/null
+++ b/build/GNULinux/NameLearn
Binary files differ
diff --git a/build/GNULinux/StringCreate b/build/GNULinux/StringCreate
new file mode 100755
index 0000000..6557221
--- /dev/null
+++ b/build/GNULinux/StringCreate
Binary files differ
diff --git a/build/GNULinux/StringLearn b/build/GNULinux/StringLearn
new file mode 100755
index 0000000..b2d104d
--- /dev/null
+++ b/build/GNULinux/StringLearn
Binary files 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#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);
+ }
+}