This week's book giveaway is in the Cloud/Virtualization forum. We're giving away four copies of Mastering Corda: Blockchain for Java Developers and have Jamiel Sheikh on-line! See this thread for details.
John Matthews wrote:Hi Eve - please could you post the rest of the code as well so I can compile it?
Sure, John! I have tried sending the complete code, but received a "Post is too long, please shorten it. Alternatively you can buy some Pie from an upper menu to increase a post limit by 10000 characters per pie slice," warning. So I have posted my code to this link https://paste.ubuntu.com/p/7ZVmwnsX22/ feel free to check it out!
Suggestions for improving/correcting print_positive_message():
(correction) The function argument should be void; if left empty it means unspecified (although it would be correct in C++).
The function should be static - it is only used in this file.
The words array should be static, otherwise it is created on the stack every time the function executes.
The word array should be a (const) one dimensional array of (const) char pointers, not a 2 dimensional array of char. The compiler will store the strings in memory for you, only using as much memory as it needs to.
Use the ARRAY_SZ() macro to give the size of the array for the modulo calculation; avoids the use of 'magic numbers' and reduces maintenance overhead.
Move the '\n' and '!' into the printf() format string because they are common to all strings.