-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprint_pointer.c
More file actions
49 lines (39 loc) · 746 Bytes
/
Copy pathprint_pointer.c
File metadata and controls
49 lines (39 loc) · 746 Bytes
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
#include "main.h"
#include <stdio.h>
int _strcmp(char *, char *);
/**
* print_pointer - Print a number in hexadecimal format
* @list: Number to print
*
* Return: Length of the number
**/
int print_pointer(va_list list)
{
char *p_buff;
int size;
p_buff = itoa(va_arg(list, unsigned long int), 16);
if (!_strcmp(p_buff, "0"))
return (print("(nil)"));
size = print("0x");
if (!_strcmp(p_buff, "-1"))
size += print("ffffffffffffffff");
else
size += print(p_buff);
return (size);
}
/**
* _strcmp - Compare two strings
* @s1: String 1
* @s2: String 2
* Return: Integer
**/
int _strcmp(char *s1, char *s2)
{
int i;
for (i = 0; s1[i] != '\0'; i++)
{
if (s1[i] != s2[i])
return (s1[i] - s2[i]);
}
return (0);
}