lawd help meh

This commit is contained in:
2023-08-20 15:38:49 +03:00
parent 1c607342b4
commit 64070c8152
4 changed files with 59 additions and 12 deletions

2
main.h
View File

@@ -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

View File

@@ -3,21 +3,49 @@
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);
}

View File

@@ -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
View 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);
}