lawd help meh
This commit is contained in:
2
main.h
2
main.h
@@ -2,7 +2,7 @@
|
||||
#define MAIN_H_
|
||||
int _printf(const char *format, ...);
|
||||
int _contains(const char *str, char c);
|
||||
int _strlen(char *str);
|
||||
int _strlen(const char *str);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
48
printf.c
48
printf.c
@@ -1,23 +1,51 @@
|
||||
#include "main.h"
|
||||
#include <stdarg.h>
|
||||
#include<stdarg.h>
|
||||
|
||||
int _printf(const char *format, ...)
|
||||
{
|
||||
unsigned int thingies; /*how many %* that aren't %*/
|
||||
char *buffer;
|
||||
int i;
|
||||
va_list stuff;
|
||||
int i = 0;
|
||||
int BUFF_SIZE = _strlen(format);
|
||||
unsigned int identifiers; /* how many %* that aren't %% */
|
||||
va_list args;
|
||||
|
||||
thingies = _contains(format, '%');
|
||||
va_start(stuff, format);
|
||||
BUFF_SIZE = _strlen(format);
|
||||
|
||||
char* buffer[BUFF_SIZE];
|
||||
|
||||
/* Number of Identifiers */
|
||||
identifiers = _contains(format, '%');
|
||||
|
||||
va_start(args, format);
|
||||
|
||||
if (!format)
|
||||
return (0);
|
||||
|
||||
while(format)
|
||||
{
|
||||
if (*format)
|
||||
if (*format == '%')
|
||||
{
|
||||
switch (*(format + 1))
|
||||
{
|
||||
case 's':
|
||||
break;
|
||||
case 'c':
|
||||
break;
|
||||
case '%':
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* something something increment i
|
||||
* by size of argument value
|
||||
* also no forgor about realloc
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
/* ERROR SCREAMING AT ME PLS HELP */
|
||||
*(buffer + i) = (format + i);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return (identifiers);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* Returns: Length of String
|
||||
*/
|
||||
int _strlen(char *str)
|
||||
int _strlen(const char *str)
|
||||
{
|
||||
if (*str)
|
||||
return (1 + _strlen(++str));
|
||||
|
||||
19
tests/str_print.c
Normal file
19
tests/str_print.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#include<../main.h>
|
||||
#include<string.h>
|
||||
|
||||
/**
|
||||
* main - Tests if '%s' works within our printf.
|
||||
*
|
||||
* Return: 0 On Failure, 1 Otherwise Success
|
||||
*/
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char test_0[] = "Hej";
|
||||
char test_1[] = "H,e,j";
|
||||
/*
|
||||
* Brain ded to think bout test cond
|
||||
*/
|
||||
|
||||
return (0);
|
||||
}
|
||||
Reference in New Issue
Block a user