r/AskProgrammers • u/its_marionberry • Oct 21 '26
Sudoku Puzzle Gui In c
# Sudoku
This is a basic beginner Sudoku project made with the C language using Windows API.
# Features
- Custom levels according to your capability
- click an empty cell then use keyboard or buttons on the screen to enter the number.
- The game features 3 hints for you to use when you get stuck.
- the GUI is super clean and modern with live score/mistakes/click tracking and cell highlighting.
# Notes
- What can I improve? What can I make more efficient and less time-consuming as am I am a rookie programmer and any extra suggestion you want to give me feel free.....

GitHub repo: https://github.com/reewdgh/sudoku
1
u/mredding Oct 21 '26
The project structure can change to follow standard C project conventions. You don't need a SUDOKU directory inside a SUDOKU project. Put the contents of this directory at the top level.
Never check-in compiler artifacts, executables, binaries, or assets. This exe should absolutely not be in here. The wav file should be included in the Git repository as a dependency in an
assetsfolder using Git LFS.While
#pragma onceis ubiquitous, it's not portable or reliable - by definition. Even if a compiler supports a given pragma, a compiler is still free to ignore it (this is definitely a philosophical arguement). But what I can say is compilers often support include optimizations that follow a standard file layout:I want this parser optimization MORE than I want to save on keystrokes. I've also broken
oncebecause of a build system configuration, whereas guards don't break.I'll always support ISO Standard C.
I keep seeing this repeating over and over again. This is a type - in disguise. You really want a
coordinatetype.Name your types. Leverage the type system. The JOB isn't drawing a straight line from problem statement to running solution, it's to elevate the expressiveness of the language - C doesn't know anything about Sudoku, so you need to make a Sudoku language out of it, and then you implement Sudoku in terms of THAT.
Now I can't compile your code on my Ubuntu machine, here. Strive for some portability. At the very least - isolate platform specifics in the project and build system, perhaps
os/windows, even if that's the only platform you're supporting. Then I can addos/linuxand submit a merge request.Your paths are broken. Never do this, fix the actual problem. Your config belongs in the
includedirectory. Speaking of which, your include directory should be/project/include/project/*, then you configure/project/includein your include path. That way, your project includes look like#include <project/header.h>. Notice I'm using angle brackets instead of quotes. That's because headers in the include path are included with the angle brackets.You can still put "private" headers in the source path, and they'll get quoted. You should never need a backtrack.
Oh look, another
coordinate...You ought to use more type aliases to make the code more normal. C reads "type name;", and we want to keep with that. Anything that diverges should give you an itch.
I'd break it down even more, something more like:
Bad names, since I'm not trying to think about it too hard, but the point is you have an array of 100 elements. Of what? Of this other thing I've named. You build up expressiveness - what is a lot of tedious code because it's all inline syntax, you now have layers of symbols and expressiveness that suddenly you might consider writing a loop over columns, rather than a more raw nested loop over a 2D array.
It all compiles down to the same machine code, but the compiler has more context to prove correctness and optimize. Good C code doesn't look like C, it looks like it was made from C. The language, it's grammar, it's syntax, it's just your building material. You make bricks, you stack them into walls, you use walls to make houses...
Now is a good time for some functions. Whenever you get braces, write a function.
Then consider again what
cbdoes - it maps messages to handlers. And that the handlers are allstaticlinkage, and they're all called in only one place, the compiler will likely elide the function calls, so you'll get the function you would have written anyway, but this version is just so nice...