Giter VIP home page Giter VIP logo

printf's Introduction

Printf

This project is my first coopriton project in ALX learning program can't wait to start!

Description

We are goning to make out own C printf function.

My partner here is MOHAMedelhennawy we are going to start to work in the project at 18 Aug 2023

Our sets up

We started by cloning the repo

git clone

Uploded our very first README.md file

vim README.md

And now we are wating for the project to start


_printf.c

the main fincion which contaiians all the other function to work togther as one

int _printf(const char *format, ...)
{
	form arr[] = {
				{'s', print_str}, {'c', print_char},
				{'i', print_INT}, {'d', print_INT},
				{'b', print_binary}, {'o', print_oct},
				{'x', print_hex}, {'X', print_HEX},
				{'u', print_unsigned}, {'S', print_string},
				{'r', print_rev}, {'R', print_rot},
				{'%', print_percent}, {'\0', NULL}};

	int i = 0, len = 0, sum = 0, flag;
	va_list List;

	if (format == NULL || (format[0] == '%' && format[1] == '\0'))
		return (-1);

	va_start(List, format);
	while (format[i] != '\0')
	{
		if (format[i] == '%')
		{
			i++;
			flag = search_f(format[i], "scidboxXuSrR%");
			if (flag >= 0)
			{
				len += arr[flag].fun(List);
				sum += 2;
				i++;
			}
			else
				_putchar('%');
		}
		else
		{
			_putchar(format[i]);
			i++;
		}
	}
	va_end(List);
	return (i + len - sum);
}

search.c

Checks if the % specfire is avlible in the funtion or not

int search_f(char f, char *c)
{
	int i;

	for (i = 0; c[i] != '\0'; i++)
	{
		if (c[i] == f)
			return (i);
	}
	return (-1);
}

_putchar.c

Our main output function which uses write keyword to wrint in the standerd output stream

int _putchar(int s)
{
	return (write(1, &s, 1));
}```

printf's People

Contributors

ehabw57 avatar

Stargazers

mohamed_el7ennawy avatar

Watchers

 avatar

printf's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.