yes
This commit is contained in:
4
printf.c
4
printf.c
@@ -19,7 +19,7 @@ int _printf(const char *format, ...)
|
|||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
|
|
||||||
identifiers = _contains(format, '%');
|
identifiers = _contains(format, '%');
|
||||||
BUFF_SIZE = _strlen(format) - identifiers;
|
BUFF_SIZE = _strlen(format) - (identifiers * 2);
|
||||||
buffer = malloc(BUFF_SIZE);
|
buffer = malloc(BUFF_SIZE);
|
||||||
|
|
||||||
if (!format) /* No string. No laundry */
|
if (!format) /* No string. No laundry */
|
||||||
@@ -38,7 +38,7 @@ int _printf(const char *format, ...)
|
|||||||
break;
|
break;
|
||||||
case 'c': /* add 1 byte and i++ */
|
case 'c': /* add 1 byte and i++ */
|
||||||
c = (char) va_arg(args, int);
|
c = (char) va_arg(args, int);
|
||||||
*(buffer + buff_idx) = c;
|
|
||||||
BUFF_SIZE += 1;
|
BUFF_SIZE += 1;
|
||||||
buff_idx += 1;
|
buff_idx += 1;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
char c = 97;
|
char c = 'c';
|
||||||
|
|
||||||
_printf("cat: %c", c);
|
_printf("cat: %c", c);
|
||||||
return (0);
|
return (0);
|
||||||
|
|||||||
@@ -1,17 +1,21 @@
|
|||||||
#include "../main.h"
|
#include "../main.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
/**
|
/**
|
||||||
* main - why does this not work! I know!
|
* main - why does this not work! I know!
|
||||||
* Return: 0...unless?
|
* Return: 0...unless?
|
||||||
*/
|
*/
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
char *str, *str2;
|
char *str, *str2, c;
|
||||||
|
|
||||||
str = "hello";
|
str = "hello";
|
||||||
str2 = " world!\n";
|
str2 = " world!\n";
|
||||||
str = _strcpy(str, str2);
|
str = _strcpy(str, str2);
|
||||||
|
c = 'c';
|
||||||
|
|
||||||
printf("%s", str);
|
printf("%s", str);
|
||||||
|
write(1, &c, 1);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user