Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
JennyHadir committed Oct 27, 2020
1 parent ec61eb7 commit aca4323
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions _printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ int (*printer(char formati))(va_list)
{'s', print_s},
{'i', print_i},
{'d', print_i},
{'R', print_rot13},
{'\0', NULL}
};
int i = 0;
Expand Down
2 changes: 2 additions & 0 deletions holberton.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ int (*f)(va_list);
int _printf(const char *format, ...);
int print_s(va_list arg);
int print_c(va_list arg);
int print_i(va_list arg);
int _putchar(char c);
char print_rot13(va_list arg)
#endif
25 changes: 25 additions & 0 deletions print_i.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "holberton.h"
#include <stdarg.h>
/**
* print_i - prints integer function
*@arg: integer to print
* Return: number of integer printed
*/
int print_i(va_list arg)
{
int ar = va_arg(arg, int);
int count = 0;
if (ar < 0)
{
_putchar('-');
count++;
ar = ar * (-1);
}
if (ar / 10)
{
print_i(ar / 10);
count++;
}
_putchar((ar % 10) + '0');
return(count);
}
31 changes: 31 additions & 0 deletions print_rot13.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "holberton.h"
#include <stdarg.h>
/**
*
*
*
*/
char print_rot13(va_list arg)
{
int i, j, count = 0;
char a[] = "AaBbCcDdEeFfGgHhIiJjKkLlMm";
char b[] = "NnOoPpQqRrSsTtUuVvWwXxYyZz";
char *s = va_arg(arg, char *);
for (i = 0; s[i]; i++)
{
for (j = 0; j < 26; j++)
{
if (s[i] == a[j])
{
_putchar(b[j]);
count++;
}
else if (s[i] == b[j])
{
_putchar(a[j]);
count++;
}
}
}
return (count);
}

0 comments on commit aca4323

Please sign in to comment.