3 ms·
If instead of this: static const char nouns[][12] = { "COPPERTONE", "JOCKEY", "TIMBERWOLF", "SAWHORSE", "PANDA", "SANDSTORM", where the 12 was calculate
by kazinator 5y ago
If instead of this:
static const char nouns[][12] = {
"COPPERTONE", "JOCKEY", "TIMBERWOLF", "SAWHORSE", "PANDA", "SANDSTORM",
where the 12 was calculated to fit the longest word, you can have pointers to string literal objects, and not have to do that:
static const char *nouns[] = {
"COPPERTONE", "JOCKEY", "TIMBERWOLF", "SAWHORSE", "PANDA", "SANDSTORM",
unless we are counting cycles here and get touching about loading a pointer from a table (which would make little sense, given that we hand off these strings to sprintf).
No code changes should be necessary elsewhere; I don't see any place that depends on nouns[x] being an array.
Speaking of sprintf, I'd add a size argument and use snprintf, plus publish a recommended minimum size constant.