Skip to content

mimicking fprintf function which prints the output in a giving file descriptor.

Notifications You must be signed in to change notification settings

hboudar/fprintf

Repository files navigation

📖 fprintf

printing data in the given file descriptor

GitHub code size in bytes Code language count GitHub top language

📜 Table of Contents

💡 Mandatory Part with Bonus

This Function : is used to print formatted output in numerous ways to the standard output stdout.

Requirements

The function is written in C language and thus needs the gcc compiler and some standard C libraries.

Instructions

1. To use the function in your code, simply include a main() with its header:

#include "ft_fprintf.h"
int  main()
{
  ft_fprintf(1, "%s\n", "hello world");
  return (0);
}

📋 Testing

Simply run this command (change X with the file of the main function):

make && gcc X

The Bonus

As a bonus to the Mandatory requirement, the function should :

  • Manage any combination of the following flags: ’-0.’ and the field minimum width under all conversions.
  • Manage all the following flags: ’# +’ (Yes, one of them is a space)

main example :

#include <stdio.h>

int main()
{
    fprintf(1, "%-7d\n", 1337);
    fprintf(2, "%07s\n", "1337");
    fprintf(3, "%+7d\n", 1337);
    return 0;
}

Running :

./a.out | cat -e
1337   $
0001337$

About

mimicking fprintf function which prints the output in a giving file descriptor.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published