| io/simple-append.c - Tilføjelse af tegn til en tekstfil. | Lektion 13 - slide 11 : 32 Program 1 |
#include <stdio.h>
#include <stdlib.h>
int main(void) {
FILE *output_file_pointer;
char *str = "Another string";
int i;
output_file_pointer = fopen("first-file", "a");
if (output_file_pointer != NULL) {
while (*str != '\0'){
fputc(*str, output_file_pointer);
str++;
}
fclose(output_file_pointer);
}
else{
printf("Could not open file. Bye.");
exit(EXIT_FAILURE);
}
return 0;
}