Skip to content

nickreactjs/printf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

0x11. C - printf

List of mandatory requirements

Build Status

Have you ever dreamed on creating your own standar library function.

well in this case we are creating our homemade printf function with the following requirements

Build Status

List of mandatory requirements

int _printf(const char *format, ...);

  • Write output to stdout, the standard output stream.

  • _printf: will print any special character if is preceded by a backslash ex: \”, \,

  • _printf: when you add a backslash then they become special: ex: \n, \a, \i

  • Returns: the number of characters printed (excluding the null byte used to end output to strings).

  • _printf: can take any number of arguments.

Read conversion specifiers when finds a %: : *%c *%s *%d *%i

Use Example

  1. create a main.c, for example:

/* Main file to test specifiers*/

/*Test function for save_c, save_s, save_d, and save_i 
Thanks to [Juan Olivares Padilla] MED 
functions */ 
int main(void)
{   unsigned int ui;
    int len;
    int len2;
    ui = (unsigned int)INT_MAX;
    len = _printf("asd%dasd %i, %d %i %d %c %s\n", ui, -42323, -999*9, 4444, 5, 'A', "Holberton");
    len2 = printf("asd%dasd %i, %d %i %d %c %s\n", ui, -42323, -999*9, 4444, 5, 'A', "Holberton");
    _printf("Length:[%d, %i]\n", len, len);
    printf("Length:[%d, %i]\n", len2, len2);
}

git clone https://github.com/nickarshadi/printf.git & cd printf & gcc -Wall -Werror -Wextra -pedantic *.c

to execute:

./a.out

ToDo

  • Fix edge cases for printf("Hello %);
  • Create an integer test file

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages