Avoid using fflush() on stdin, its behavior is undefined in standard C. Some compilers might handle it properly, but you run the risk of getting weird stuff happening.
Also, use fgets() instead of scanf when reading user input.
Here, the input is formated so scanf is okay, but get used to fgets instead, it’s much safer.
It’s also faster than scanf.
Be aware though that fgets stores the ending ‘\n’ at the end of the buffer.
Another thing : using &s as the parameter for scanf means you’re sending it the address of your array, not your array itself.
%s expect a pointer to a character. If you send it &s, it’s a pointer to an array of character. You should send only s, which will decay to a pointer to the first character of the array.
Turns out the address of an array is also the address of its first byte, so it works out fine there…
Unless you use some special flags when compiling.
-Wall will raise a warning saying the argument is of unexpected type,
and combined with -Werror it will make the warning an error and prevent compilation.
I suggest you compile with extra flags, it will help in making sure everything in your code is as it should be.
You could create an alias for “gcc -Wall -Wextra” to get warnings on subtle errors but not prevent compilation.