-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtask_15.c
More file actions
41 lines (39 loc) · 708 Bytes
/
task_15.c
File metadata and controls
41 lines (39 loc) · 708 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
#include "holberton.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
/**
* print_R - prints a string in rot13
* @R: string to print
* Description: replaces a letter with the 13th letter after it
* Return: number of chars printed
*/
int print_R(va_list R)
{
char *s;
unsigned int i, k;
int j = 0;
char a[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
char b[] = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm";
s = va_arg(R, char *);
if (s == NULL)
s = "(ahyy)";
for (i = 0; s[i]; i++)
{
for (k = 0; a[k]; k++)
{
if (a[k] == s[i])
{
_putchar(b[k]);
j++;
break;
}
}
if (!a[k])
{
_putchar(s[i]);
j++;
}
}
return (j);
}