42_EXAM icon indicating copy to clipboard operation
42_EXAM copied to clipboard

ft_countdown maybe bugged?

Open lucAsC87 opened this issue 1 year ago • 6 comments

I'm pretty sure there's an issue in this exercise: my file is in a folder called ft_countdown, the subject is:

Assignment name : ft_countdown Expected files : ft_countdown.c Allowed functions: write

Write a program that displays all digits in descending order, followed by a newline.

Example: $> ./ft_countdown | cat -e 9876543210$ $>

My code is

#include <unistd.h>

void	ft_countdown(void)
{
	write(1, "9876543210", 10);
	write(1, "\n", 1);
}

int	main(void)
{
	ft_countdown();
}

It does compile and my output is 9876543210$ Am i getting something wrong? Thanks anyway, it's a great way to train yourself and I can't wait to try the new exam rank :)

lucAsC87 avatar May 31 '23 22:05 lucAsC87

Same issue...

I got a similar output code, which is

#include <unistd.h>

int	main(void)
{
	char	c;

	c = '9';
	while (c >= '0')
	{
		write(1, &c, 1);
		c--;
	}
	write(1, "\n", 1);
	return (0);
}

I got this trace as well :



ld: can't map file, errno=22 file 'ft_countdown' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

9876543210$
\n-------
9876543210$
\n-------

There is absolutely nothing complicated, I still got failures... bit frustrating... I do appreciate the tool tho, hope it'll be resolved soon 😃

maitreverge avatar Jun 07 '23 14:06 maitreverge

Hi, does it works with another exercices ?

JCluzet avatar Jun 07 '23 14:06 JCluzet

Hi, I've used a similar method with another exercise and it worked just fine! Thanks for your time

lucAsC87 avatar Jun 07 '23 14:06 lucAsC87

Thanks, what is your OS ?

JCluzet avatar Jun 07 '23 14:06 JCluzet

Ubuntu 22.04.2 LTS

lucAsC87 avatar Jun 07 '23 14:06 lucAsC87

Hello @JCluzet. It's my last comment under this issue to avoid mixing things up. If you want me to open a separate issue, let me know !

It worked just fine with ft_print_numbers with another first exercice, which code source was :

#include <unistd.h>

void	ft_print_numbers(void)
{
	char	c;

	c = '0';
	while (c <= '9')
	{
		write(1, &c, 1);
		c++;
	}
}

For my part, I work under macOS 12.6.3, under a M1 chip. Hope it helps.

maitreverge avatar Jun 07 '23 14:06 maitreverge