1#include <stdio.h>
2#include <stdlib.h>
3#include <sys/types.h>
4#include <unistd.h>
5
6void my_write(FILE *fp, char *str)
7{
8 fprintf(fp, "%s", str);
9}
10
11int main(void)
12{
13 char *str = "test text\n";
14 FILE *fp;
15
16 fp = fopen("test.txt", "a");
17 if (fp == NULL)
18 {
19 printf("Couldn't open file\n");
20 return 1;
21 }
22 my_write(fp, str);
23
24 fclose(fp);
25
26 return 0;
27}
28