- Code: Select all
char MapName[256] = "Name";
char line[256];
int found = 0;
FILE * levs = fopen("levels.text", "r");
while(fgets(line, 255, levs)) {
if(strcmp(line, MapName) == 0) {
found = 1;
}
}
fclose(levs);
if(!found) {
FILE * GO = fopen("levels.txt", "a+");
fprintf(GO, "%s\n", MapName);
fclose(GO);
}