#error: control reaches end of non-void function. What does this mean?
11 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
Compiler Output
<source>: In function 'Choice convert(char)':
<source>:25:1: warning: control reaches end of non-void function [-Wreturn-type]
25 | }
| ^
Welcome to Chin Chan Pu!
Would you like to play in dynamic mode? (Enter 0 for yes, any other number for no):
Enter r for rock, p for paper, s for scissors, or q to quit: Invalid input. Please try again.
Enter r for rock, p for paper, s for scissors, or q to quit: Invalid input. Please try again.
Enter r for rock, p for paper, s for scissors, or q to quit: Invalid input. Please try again.
Enter r for rock, p for paper, s for scissors, or q to quit: Invalid input. Please try again.
Enter r for rock, p for paper, s for scissors, or q to quit: Invalid input. Please try again.
Enter r for rock, p for paper, s for scissors, or q to quit: Invalid input. Please try again.
Enter r for rock, p for paper, s for scissors, or q to quit: Invalid input. Please try again.
Enter r for rock, p for paper, s for scissors, or q to quit: Invalid input
scimfear#4088 | 142ms | c++ | x86-64 gcc 12.2 | godbolt.org
the problem is that the convert function doesn't cover every possible value of char and in some cases may exit the function without returning a value
how would you go about fixing the issue?
making a default option at the end
ah so defaulting and then returning so that with an invalid input it defaults to what i choose it to be