Issue about printf

Hello there,

I’ve got an issue in the Chuck Norris level, when giving my answer : I write :

printf("%s\n", result);

and I only get this

0 0 00 0000 0 00 


Fail
Found:    ""
Expected: "0"

Even though my answer, which is the zeroes and the spaces, seems to be correct. However, when I put “manually” :

printf("0 0 00 0000 0 00\n");

It works perfectly. I don’t understand, my answer “result” is a string type…

char result[300];

maybe you store '\0' or 0 instead of '0'

also try to output to the standard error output, you will see if you string matches.

Thanks for answering,

By reducing the size of answer, and doing :

fprintf(stderr, "%s\n",result);
        printf("%s\n",result);

I get this :

0 0 00 0000 0 00 
0 0 00 0000 0 00 


Fail
Found:    "0 0 00 0000 0 00 "
Expected: "0 0 00 0000 0 00"

I really don’t understand how to solve this. Anyways, thanks for helping

you have a trailing whitespace, remove it and you’ll be good i guess
try changing your code into:

fprintf(stderr, "'%s\n'",result);

so that you will see the whitespace

1 Like

That worked like a charm, it was the trailing whistespace, just had to remove it.

Thanks a lot !

Edit : How to put a post as solved?