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_ #define MAIN_H_
int _printf(const char *format, ...); int _printf(const char *format, ...);
int _contains(const char *str, char c); int _contains(const char *str, char c);
int _strlen(char *str); int _strlen(const char *str);
#endif #endif

View File

@@ -1,23 +1,51 @@
#include "main.h" #include "main.h"
#include <stdarg.h> #include<stdarg.h>
int _printf(const char *format, ...) int _printf(const char *format, ...)
{ {
unsigned int thingies; /*how many %* that aren't %*/ int i = 0;
char *buffer; int BUFF_SIZE = _strlen(format);
int i; unsigned int identifiers; /* how many %* that aren't %% */
va_list stuff; va_list args;
thingies = _contains(format, '%'); BUFF_SIZE = _strlen(format);
va_start(stuff, format);
char* buffer[BUFF_SIZE];
/* Number of Identifiers */
identifiers = _contains(format, '%');
va_start(args, format);
if (!format) if (!format)
return (0); return (0);
while(format) 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 * Returns: Length of String
*/ */
int _strlen(char *str) int _strlen(const char *str)
{ {
if (*str) if (*str)
return (1 + _strlen(++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);
}