Hey everyone! I recently wrote a level 2 application in C that checks the creation of simple files and directories. I'm looking to get some feedback from experienced developers on my code. Please bear with me as I might make mistakes in English since I'm not a native speaker. You can find my code files here: level02.h [gist](https://gist.github.com/mrEliotS/6bdb5dff423d0f76e73dfb8b422b9315) and level02.c [gist](https://gist.github.com/mrEliotS/b876bcf24e401e67f9e8eb2aad104f23). Thanks a lot!
3 Answers
Regarding the platform check, instead of just indicating that Windows is unsupported, use the #error directive during preprocessing. This way, compilation stops with a relevant message. You should also consider supporting Cygwin, which is a popular environment for running Linux programs on Windows, as it may ease the process for users. Check documentation to see how to handle platform specifics efficiently. Some compilers have different macros for identifying Windows, so research that too!
From what I see, the main issues are clarity and consistency. Code should not only work but also be easy to read. You're missing indents, and you should place function comments before the function itself. Also, your use of Hungarian notation can complicate things—try using more intuitive variable names. For example, instead of using prefixes like 'lb_', simple names like 'fileExists' would make your code much clearer. Also, be consistent with your naming conventions—pick either snake_case or camelCase and stick to it. Spaces also help with readability, so use them!
Regardless of style, when your codebase grows, it can be hard to maintain clarity in names. What's your best suggestion to keep variable names clear as the project expands?
Thanks for your comments! I will definitely work on my variable names and focus on clarity as the project grows!
Your code is definitely an improvement, but there's still a lot of room for better formatting. Proper indentation is crucial for readability, so make sure to maintain it throughout your code. Also, avoid submitting every single program for review; it's better to focus on specific functionalities. Check out the guidelines for code reviews to understand better what to include.
Thanks for the advice! I appreciate it. I'll definitely look into the #error directive and see how I can make my application friendlier for different environments.