Ok, so the only way to make this work is to put ; at the end of line 63... Why? It is a ELSE :/
Also it doesn't solve the problem I am having. It loops after the IF. Now it doesnt even write the CHHHH to disk, only NHHHH's.
It should write CHHHH to disk bc of the if in void write_File(char* randString)... :/
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//Different Combos = H B C N P O S Se F Cl Br I F
char randString[20] = "";
int finish = 0;
void write_File(char* randString);
char* random(char* randString, int finish);
int main()
{
while(finish != 1)
{
strcpy(randString, random(randString, finish));
write_File(randString);
}
return(0);
} //END MAIN
void write_File(char* randString)
{
FILE* fts;
fts = fopen("data.dat", "a");
if (fts)
{
fprintf(fts, "\n%s", randString);
fclose(fts);
}
else
{
printf("Error writing to file!\n");
}
}
char* random(char* randString, int finish)
{
int check = 1;
if(strcmp(randString,"") == 0)
{
strcpy(randString, "CHHHH");
}
else(strcmp(randString,"") != 0);
{
if (strcmp(randString, "CHHHH") == 0)
{
while(check != 0)
{
strcpy(randString,"NHHHH");
check = 0;
}
}
printf("It infinite loops here");
finish = 1;
}
return(randString);
}