This commit is contained in:
hexplor
2026-03-31 05:57:30 +02:00
parent b16bc96a61
commit 9c1b260697
2 changed files with 4 additions and 3 deletions
BIN
View File
Binary file not shown.
+4 -3
View File
@@ -78,6 +78,7 @@ static int search_end(FILE* file){
} }
static int insert_into_section(FILE* file, const char* name_out, const char* toInsert){ static int insert_into_section(FILE* file, const char* name_out, const char* toInsert){
fseek(file, 0, SEEK_SET);
if (strlen(name_out) > 48) if (strlen(name_out) > 48)
return -1; return -1;
int end = search_end(file); int end = search_end(file);
@@ -98,7 +99,7 @@ static int insert_into_section(FILE* file, const char* name_out, const char* toI
size_t rded = 0; size_t rded = 0;
while (1){ while (1){
if (count == end) if (count == end)
fprintf(out, "%s\n", toInsert); fprintf(out, "%s", toInsert);
if (getline(&line, &rded, file) == -1) if (getline(&line, &rded, file) == -1)
break; break;
fprintf(out, "%s", line); fprintf(out, "%s", line);
@@ -106,7 +107,7 @@ static int insert_into_section(FILE* file, const char* name_out, const char* toI
line = NULL; line = NULL;
count++; count++;
} }
/* FAIRE LE QUINE AUTOMATIQUE */
fclose(out); fclose(out);
return 0; return 0;
} }
@@ -121,7 +122,7 @@ int main(int argc, char **argv)
size_t rded = 0; size_t rded = 0;
if (!in) if (!in)
return 1; return 1;
insert_into_section(in, argv[1], "INSERTED"); insert_into_section(in, argv[1], "INSERTED\n");
free(line); free(line);
fclose(in); fclose(in);
return 0; return 0;