-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.c
executable file
·107 lines (60 loc) · 1.18 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "main.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/**
*
* * simple_print_buffer - prints buffer in hexa
*
* * @buffer: the address of memory to print
*
* * @size: the size of the memory to print
*
* *
*
* * Return: Nothing.
*
* */
void simple_print_buffer(char *buffer, unsigned int size)
{
unsigned int i;
i = 0;
while (i < size)
{
if (i % 10)
{
printf(" ");
}
if (!(i % 10) && i)
{
printf("\n");
}
printf("0x%02x", buffer[i]);
i++;
}
printf("\n");
}
/**
*
* * main - check the code for
*
* *
*
* * Return: Always 0.
*
* */
int main(void)
{
char *p;
int i;
p = malloc(sizeof(char) * 10);
p = _realloc(p, sizeof(char) * 10, sizeof(char) * 98);
i = 0;
while (i < 98)
{
p[i++] = 98;
}
simple_print_buffer(p, 98);
free(p);
return (0);
}