-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patho_func.c
87 lines (70 loc) · 1.17 KB
/
o_func.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
#include "main.h"
/* Functions 0x11. C - printf */
/**
* rot13 - Encodes a string using rot13
* @a: String to encode
* Description: Encodes a string using rot13
* Return: char
*/
char *rot13(char *a)
{
int i;
int j;
char let[52] = "abcdefghijklmnopqrstuvwxyzABCDEFGJIJKLMNOPQRSTUVWXYZ";
char rot[52] = "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGJIJKLM";
for (i = 0; *(a + i) != '\0'; i++)
for (j = 0; j < 52; j++)
if (*(a + i) == let[j])
{
*(a + i) = rot[j];
break;
}
return (a);
}
/**
* get_rot - Takes va_list and return a string
* @va: va_list
*
* Return: char
*/
char *get_rot(va_list va)
{
char *c;
char *r;
c = va_arg(va, char *);
r = rot13(c);
return (r);
}
/**
* get_rev - Takes va_list and return a string
* @va: va_list
*
* Return: char
*/
char *get_rev(va_list va)
{
char *c;
int len;
c = va_arg(va, char *);
len = 0;
while (*(c + len) != 0)
len++;
_reverse(c, (len + 1));
return (c);
}
/**
* get_binary - Takes va_list and return a string
* @va: va_list
*
* Return: char
*/
char *get_binary(va_list va)
{
int i;
char *c;
i = va_arg(va, int);
c = _itoa(i, 2);
if (c == NULL)
return (NULL);
return (c);
}