Skip to content

ft_printf (42cursus) 2022-2023. Remake printf. A project usefull for the next projects. The aim is to learn how variable size arguments works.

License

Notifications You must be signed in to change notification settings

aabduvak/ft_printf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧰 ft_printf

Because putnbr and putstr aren’t enough

GitHub code size in bytes Number of lines of code Code language count GitHub top language GitHub last commit


💡 About the project

This project is pretty straight forward. You will recode printf. Hopefully you will be able to reuse it in future project without the fear of being flagged as a cheater. You will mainly learn how to use variadic arguments.

What is ft_printf?

ft_printf is an individual project at 42 that requires us to create a function similar to the printf from <stdio.h>. The function ft_printf() (the name comes from “print formatted”) prints a string on the screen using a “format string” that includes the instructions to mix several strings and produce the final string to be printed on the screen.

Application flow

Click here for the interactive link.

Objectives

  • Unix logic

Skills

  • Rigor
  • Unix
  • Algorithms & AI

My grade

List of functions:

  • ft_convert - converts num to related numerical base.
  • ft_putnbr - prints the number on the screen.
  • ft_putstr - prints given string on the screen.
  • ft_putchar - prints given character on the screen.
  • ft_putunbr - prints given number on the screen (only positive).
  • ft_putptr - prints given data by hexidecimal numerical base on the screen
  • ft_strlen - computes length of given string.
  • ft_printf - prints a string on the screen using a “format string” that includes the instructions to mix several strings and produce the final string to be printed on the screen.

🛠️ Usage

Follow the steps below

Instructions

1. Clone the repository from github

git clone https://github.com/abdulazizabduvakhobov/ft_printf && cd ft_printf/

2. Compile the library by Makefile To compile the library, go to its path and run:

For all mandatory functions:

 make

3. Create main.c to test the funtion:

touch main.c

4. Using it in your code

To use the function in your code, simply include its header:

#include "ft_printf.h"

Example of a main

#include "ft_printf.h"

int main(void)
{
  ft_printf("%s", "Hello World");
  ft_printf("%c", '\n');
  ft_printf("%d", 123456789);
  ft_printf("%c", '\n');
  ft_printf("%X", 987654321);
 return (0);
}

/**
* output: 
* Hello World
* 123456789
* 3ADE68B1
**/

5.After coding, you have to compile your code with libftprintf.a library like an example below

gcc main.c libftprintf.a -I./sources && ./a.out
# Done :)

Requirements

The library is written in C language and needs the gcc compiler and some standard C libraries to run.

Usefull make command

1. Cleaning all binary (.o) files

To clean all files generated binary files while doing a make, go to the path and run:

 make clean

2. Cleaning all binary (.o) and executable files (.a)

To clean all files generated while doing a make, go to the path and run:

 make fclean

2. Checking Norminette standart

To check Norminette errors of all files, simply go to the path and run:

 make norm

3. Help command

To get information about command, run:

 make help

📋 Testing

You can use any of this third party testers to test the project

About

ft_printf (42cursus) 2022-2023. Remake printf. A project usefull for the next projects. The aim is to learn how variable size arguments works.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published