0
Why it didn't work
Hola everyone l am stocked about why when I input like what a wonderful world \n\n# but it just show me the num of words without \n num? Help me please https://code.sololearn.com/cq7hT18f6jkk/?ref=app
2 Answers
+ 1
Because the '\n' character is a new line, not a literal \n. Try entering this:
hello
world
#
// not "hello world#"
0
First, you are counting in W_num the number of characters, not the number of words.
Second, your code is correct, just be sure to input a newline instead of \n (byte value 0xA).
You can test it adding a printf("%x ", num); as first instruction of your while loop.
If you for example input
solo
learn
#
and click SUBMIT, the output will be, as expected
73 6f 6c 6f a 6c 65 61 72 6e a There are 2 11