-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path1415.c
56 lines (48 loc) · 951 Bytes
/
1415.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
#include "holberton.h"
/**
* print_reverse - prints a string in reverse
* @r: the variadic argument brought from printf function
* Return: amount of characters printed
*/
int print_reverse(va_list r)
{
int i = 0, lenr = 0;
char *s = va_arg(r, char *);
while (s[i] != '\0')
i++;
lenr = i;
i--;
while (i >= 0)
{
_putchar(s[i]);
i--;
}
return (lenr);
}
/**
* print_rot13 - prints a string encrypted with rot13
* @R: the variadic argument brought from printf function
* Return: amount of characters printed
*/
int print_rot13(va_list R)
{
int len = 0;
int i, j;
char *s = va_arg(R, char *);
char alpha[] =
"\n! aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ";
char replace[] =
"\n!_ nNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmM";
for (i = 0; s[i] != '\0'; i++)
{
for (j = 0; j <= 55; j++)
{
if (s[i] == alpha[j])
{
len = len + _putchar(replace[j]);
break;
}
}
}
return (len);
}