top of page
Search

The _printf( ) Collaborative Project at ALX_HOlBERTON School

mercyjay011
Nov 5, 2022
2 min read

AUTHOR: MERCY IGWE in collaboration with NDUKE SUNDAY













How I converged My “_Printf” Project at ALX



Before I go ahead with the concepts of c programming language which I was taught at ALX_HOlBERTON School, I would like to express how I was able to achieve my first collative project which was named the “_printf” project at “0x11. C — printf” on alx curriculum,


I'll describe my experience with the project and what _printf is all about, as well as provide some examples.


The pair programming project was completed as part of the ALX curriculum for low-level programming and algorithms (a leadership, employment, and entrepreneurship development organization). We were tasked with creating a function code called "_printf" that emulates the C standard library function printf ().


Being a beginner, the project was really tough, first I was paired with my partner by the name NDUKE SUNDAY. I had a lot of brainstorming with my partner and white-boarding with several google meetings, we were able to start the coding journey.

For each project or task Resources, requirements, and sample codes or prototypes were given. The mandatory tasks came off a bit of ease, we were told to handle certain format specifiers after we have gone through the resources and used the prototype that was provided. Then we moved to the advanced tasks which become complex. Luckily, the flowchart, pseudocode, and proper review of the secrets of the printf function helped to solve the tasks.


After completing each task we compiled and tested our code with the gcc flags “gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c ” and made sure all edge cases were met with the correct output displayed. Then we pushed it to our printf repository on GitHub to make use of the checker.


This project has taught me a lot about variadic functions, system calls, group project management on GitHub, and different approaches to algorithmic problems. The most difficult part was determining the scope of what "printf()" can do and then trying to match it within the constraints imposed by ALX.


DETAILS ABOUT THE _printf() FUNCTION.


IN THIS PROJECT THE PROTOTYPE THAT WAS GIVEN WAS

Prototype:


int _printf(const char *format, …);


The _printf() prototype is defined in the header file "main.h." When you use the _printf() function, the string specified by the format is printed to the standard output "stdout." The format may also include some specifiers beginning with a "%" that specify how subsequent variable arguments (accessed via the variable-length argument facilities of stdarg) are converted for output.

Simply put, they function as additional arguments to the _printf() function.


The function OUTPUT

  • The number of characters written if successful (excluding the terminating null byte used to end output to strings)

  • ·A negative value, if failed.

Example:

#include "main.h"

int main(void)
{ 
  char str[] = " Alx!"; 
  printf("Hello,%s\n", str); 
  return (0); 
}

Output:

Hello Alx!

  • Because _printf() is a variadic function, we can pass an indefinite number of arguments to it.


Also, with the progressive effort of ALX Africa mentors in training our grit mindset in doing hard things. We were able to complete the project successfully

Below is the resource I found useful during this project Enjoy.


 
 
 

Comments


bottom of page