-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
62 lines (56 loc) · 1.56 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <stdio.h>
#include "libftprintf.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <locale.h>
static void WriteFrmtd(char *format, ...)
{
int fd = open("text2.txt", O_WRONLY|O_CREAT,0640);
va_list args;
/************/
va_start(args, format);
vprintf(format, args);
va_end(args);
/************/
va_start(args, format);
vdprintf(fd, format, args);
va_end(args);
/************/
va_start(args, format);
ft_vprintf(format, args);
va_end(args);
/************/
va_start(args, format);
ft_vdprintf(fd, format, args);
va_end(args);
/************/
close(fd);
}
int main()
{
//setlocale(LC_ALL, "");
printf("coucou %lc coucou\n", L'ݗ');
ft_printf("coucou %lc coucou\n", L'ݗ');
int fd = open("text.txt", O_WRONLY|O_CREAT,0640);
char *s;
s = malloc(sizeof(char) * 100);
FILE *f = fopen("text1.txt", "r+");
WriteFrmtd("hello %s %c\n", "world", '!');
printf("printf: hello %s %c\n", "world", '!');
dprintf(fd, "dprintf say hello %s %c\n", "world", '!');
fprintf(f, "fprintf say hello %s %c\n", "world", '!');
/*******************/
s = malloc(sizeof(char) * 100);
sprintf(s, "hello %s %c\n", "world", '!');
printf("sprintf: %s\n", s);
ft_sprintf(s, "hello %s %c\n", "world", '!');
printf("fsprint: %s\n", s);
/*******************/
ft_printf("hello %s %c\n", "world", '!');
ft_dprintf(fd, "hello %s %c\n", "world", '!');
ft_fprintf(f, "hello %s %c\n", "world", '!');
close(fd);
fclose(f);
return (0);
}