-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandR.c
More file actions
50 lines (44 loc) · 947 Bytes
/
randR.c
File metadata and controls
50 lines (44 loc) · 947 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
50
#include "main.h"
/**
* print_rev_string - print reversed string
* @arg: va_list argument containing the string
* Return: number of characters printed
*/
int print_rev_string(va_list arg)
{
char *str = va_arg(arg, char *);
int count = 0;
if (!str)
str = "(null)";
count += print_rev(str);
return (count);
}
/**
* print_rot13 - print rot13'ed string
* @arg: va_list argument containing the string
* Return: number of characters printed
*/
int print_rot13(va_list arg)
{
char *str = va_arg(arg, char *);
int count = 0;
char rot;
while (*str != '\0')
{
rot = *str;
if ((rot >= 'A' && rot <= 'Z') || (rot >= 'a' && rot <= 'z'))
{
if (rot >= 'A' && rot <= 'M')
rot += 13;
else if (rot >= 'N' && rot <= 'Z')
rot -= 13;
else if (rot >= 'a' && rot <= 'm')
rot += 13;
else if (rot >= 'n' && rot <= 'z')
rot -= 13;
}
count += _putchar(rot);
str++;
}
return (count);
}