JCluzet / GrademeBash

Automatic testing for all 42, C and CPP projects. Makefile relink, Header wrong name, Coplien Form and so much more.
296 stars 11 forks source link

Rank2, ft_atoi_base is wrong? #34

Open Lineath opened 1 year ago

Lineath commented 1 year ago

I think this is wrong, what do you whink?

Seem that you are using atoi_base from piscine exercices, its not the same in the exam!

./a.out "Ceci permet de decouvrir le fonctionnement de ton ft_atoi_base." "16" 🗝 EXPECTED OUTPUT: 3308$

Seems that you are triming the string to the first valid part ("Cec" 0x3308), like the subject of the piscine. but the exam subject is different:

` Write a function that converts the string argument str (base N <= 16) to an integer (base 10) and returns it.

The characters recognized in the input are: 0123456789abcdef Those are, of course, to be trimmed according to the requested base. For example, base 4 recognizes "0123" and base 16 recognizes "0123456789abcdef".

Uppercase letters must also be recognized: "12fdb3" is the same as "12FDB3".

Minus signs ('-') are interpreted only if they are the first character of the string.

Your function must be declared as follows:

int ft_atoi_base(const char *str, int str_base); `

I think the whole string (where aplicable) must ve converted then manage any error (int ranges etc), i just failed the real exam on this, asked the staff but no luck, they wont answer...

Lineath commented 1 year ago

Want to add:

Its even worse, exam subject do not let you return anything except a valid 32 int, so no error management (exit codes) or -1, nothing. A string like "Ceci permet de decouvrir le fonctionnement de ton ft_atoi_base.", its gonna generate BIG numbers outside int range.

"...string argument str (base N <= 16) to an integer (base 10) and returns it..."

Seems that str argument can only contain characters that fit on base 16 or less?? what about big numbers? lets say "FFFFFFFFFFFF" (281.474.976.710.655) this way out of range, but you are no allowed to return nothing but "int".

I dont get it.