![]() ![]() However, when you find yourself naming variables foo1, foo2, etc, or first_foo, second_foo, etc, you should think adding an array dimension. A 2-d array where one dimension has only 1 entry is silly.Why sudoku_second_box instead of second_box? But see the next point. You use descriptive names, but sometimes they seem pointlessly long.Define constants with good, descriptive names, and use them everywhere. Declare them in an appropriate function and pass them as needed. Global variables are evil, read this: Global Variables Are Bad.If you're going to hard-code the initial value of the puzzle, then use an array intializer.So it is warning you that there's is a chance your function wont return a value. You only use if and else if (no plain else at the end as a "default" or "catch-all" case), meaning the 9 returns only happen when some run-time condition is met the compiler just can't know whether that is guaranteed to happen all the time. Note, for line 231, it looks like you do return a variable in all cases, but the compiler can't tell for sure. Failure to do so results in undefined behavior (see Question 11.33 - that FAQ is an excellent resource, spend some time perusing it when you can). If you don't want to return a value from a function, declare it with void return type, otherwise you must always return a valid value. ![]() Sudoku.c:231:1: warning: control reaches end of non-void function Sudoku.c:355:1: warning: control reaches end of non-void function Sudoku.c:557:10: warning: unused variable ‘response’ Sudoku.c: In function ‘set_to_value_or_space’: Sudoku.c:289:9: warning: unused variable ‘j’ Sudoku.c:289:12: warning: unused variable ‘k’ Sudoku.c:289:15: warning: unused variable ‘l’ Gcc -Wall -ggdb3 -pedantic -std=gnu99 -O0 -o sudoku sudoku.c -lm -lpthread -lrt
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |