-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcases3.c
57 lines (51 loc) · 1013 Bytes
/
cases3.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
#include "main.h"
/**
* r_case - function for r case
* @ap: String
* @buff: buffer
* @print_len: actual position of buff
* Return: Last position on buff
*/
int r_case(va_list ap, char *buff, int print_len)
{
char *s;
char *aux;
int s_len;
aux = va_arg(ap, char*);
if (aux == NULL)
aux = "(null)";
s_len = _strlen(aux);
s = malloc((sizeof(char) * s_len) + 1);
if (s == NULL)
return (1);
_strcpy(s, aux);
rev_string(s);
print_len = replace(buff, s, print_len);
free(s);
return (print_len);
}
/**
* R_case - function for R case
* @ap: String
* @buff: buffer
* @print_len: actual position of buff
* Return: Last position on buff
*/
int R_case(va_list ap, char *buff, int print_len)
{
char *s;
char *aux;
int s_len;
aux = va_arg(ap, char*);
if (aux == NULL)
aux = "(null)";
s_len = _strlen(aux);
s = malloc((sizeof(char) * s_len) + 1);
if (s == NULL)
return (1);
_strcpy(s, aux);
s = rot13(s);
print_len = replace(buff, s, print_len);
free(s);
return (print_len);
}