Code Monkey home page Code Monkey logo

42-piscine's Issues

new into programming and some questions :)

hey
im working with your repo to prepare me for my piscine and i stumble over some points that i dont under stand:
here

its sad that there is no subject that i can look what that task was but i tried to understand the code so

#include <unistd.h>

void ft_putchar(char c)
{
write(1, &c, 1);
}

void ft_putnbr(int n)
{
(n < 0 ? ft_putchar('-') : 1); // why we need this part when we have no negativ input of argc // or can there be a negativ input? :) i thought its just counting the arguments that i typed in the terminal :D
n *= (n > 0 ? -1 : 1); //same as here
(n <= -10 ? ft_putnbr(-(n / 10)) : 1);
ft_putchar('0' - n % 10);
}

int main(int ac, char **av)
{
(void)av;
ft_putnbr(ac - 1);
write(1, "\n", 1);
return (0);
}

and is this not almost the same code out of c06 ex01:
#include <unistd.h>

int main(int argc, char **argv)
{
int i;
int j;

j = 1;
while (j < argc)
{
	i = 0;
	while (argv[j][i])
	{
		write(1, &argv[j][i], 1);
		i++;
	}
	write (1, "\n", 1);
	j++;
}

}

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.