-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memset.c
More file actions
61 lines (56 loc) · 2.21 KB
/
Copy pathft_memset.c
File metadata and controls
61 lines (56 loc) · 2.21 KB
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
/* ************************************************************************** */
/* */
/* /#/ |#/|#| */
/* ft_memset.c /#/ |/ |#| */
/* /#/ /#/ */
/* By: nepcohen <nepcohen@learner.42.tech> /#/ /#/ */
/* /#/____ |#| /| */
/* Created: 2026/05/25 14:54:26 by nepcohen |#######| |#|/#| */
/* Updated: 2026/05/26 13:06:41 by nepcohen |#| NEPH_ */
/* */
/* ************************************************************************** */
//#include "libft.h"
#include <strings.h>
/* PROG ===================================================================== */
void *ft_memset(void *s, int c, size_t n)
{
size_t count;
unsigned char *p;
p = (unsigned char*)s;
count = 0;
while (count < n)
{
p[count] = (unsigned char)c;
count++;
}
return (s);
}
/* MAIN ===================================================================== */
#include <stdio.h>
#include <stdlib.h>
void display(void *playS, int playC, size_t playN)
{
unsigned char *result;
printf("Avant : `%s`, Incr `%d`\n", (char *)playS, playC);
printf("Ram : `%p`, Repeat : `%zu`\n", playS, playN);
result = ft_memset(playS, playC, playN);
printf("==========================\n");
printf("Apres : `%s`\n, Incr : `%d`\n", (char *)result, playC);
printf("Ram : `%p`, Repeat : `%zu`\n", result, playN);
}
int main (int argc, char **argv)
{
//char init[] = "ceci est la chaine initiale";
if (argc != 4)
printf("Nombre d'argument non valide");
else
{
// display(init, argv[2][0], atoi(argv[3]));
// printf("\n");
display(argv[1], argv[2][0], atoi(argv[3]));
}
return (0);
}
/* ========================================================================== */
/* END =================================================== 42_ ============== */
/* ======================================================= NEPHCODE ========= */