Skip to content

Commit 2a9b523

Browse files
committed
fix bugs in 3-print_all and betty style in variadic_functions.h
1 parent 9a3bd6b commit 2a9b523

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

0x10-variadic_functions/3-print_all.c

+19-6
Original file line numberDiff line numberDiff line change
@@ -4,58 +4,71 @@
44
/**
55
* print_char - prints a char.
66
*
7-
* @c: char
7+
* @arg: va_list arg
88
*
99
* Return: Nothing
1010
*/
1111
void print_char(va_list arg)
1212
{
1313
char c = va_arg(arg, int);
14+
1415
printf("%c", c);
1516
}
1617

1718
/**
1819
* print_int - prints a integer
1920
*
20-
* @i: integer
21+
* @arg: va_list arg
2122
*
2223
* Return: Nothing
2324
*/
2425
void print_int(va_list arg)
2526
{
2627
int i = va_arg(arg, int);
28+
2729
printf("%i", i);
2830
}
2931

3032
/**
3133
* print_float - prints a float
3234
*
33-
* @f: float.
35+
* @arg: va_list arg
3436
*
3537
* Return: Nothing
3638
*/
3739
void print_float(va_list arg)
3840
{
3941
float f = va_arg(arg, double);
42+
4043
printf("%f", f);
4144
}
4245

4346
/**
4447
* print_str - prints a string
4548
*
46-
* @str: string
49+
* @arg: va_list arg
4750
*
4851
* Return: Nothing
4952
*/
5053
void print_str(va_list arg)
5154
{
5255
char *str = va_arg(arg, char *);
56+
5357
if (str == NULL)
58+
{
5459
printf("(nil)");
55-
else
56-
printf("%s", str);
60+
return;
61+
}
62+
printf("%s", str);
5763
}
5864

65+
/**
66+
* print_all - prints all data types variables
67+
*
68+
* @format: allowed formats.
69+
*
70+
* Return: Nothing.
71+
*/
5972
void print_all(const char * const format, ...)
6073
{
6174
int index = 0, index2 = 0;

0x10-variadic_functions/variadic_functions.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ void print_numbers(const char *, const unsigned int, ...);
77
void print_strings(const char *, const unsigned int, ...);
88
void print_all(const char * const, ...);
99

10-
typedef struct {
10+
/**
11+
* struct formats_struct - allowed formats to be printed.
12+
*
13+
* @type: points to the type char
14+
* @func: points to the print func
15+
*/
16+
typedef struct formats_struct
17+
{
1118
char *type;
1219
void (*func)(va_list arg);
1320
} format_func;

0 commit comments

Comments
 (0)