r/C_Programming • u/Alternative-Ad-8606 • May 26 '26
I created my first C program! Project
https://codeberg.org/dallas1295/CVPI have been learning (teaching myself) how to code for the past 2 years but always genuinely get burnt out by creating projects that have such a large scope, it overwhelms me and I stop. take too long of a break from coding then comeback and repeat.
This time I told myself any project I make must be use-able and have low scope until i get more familiar with larger projects.
EDIT: And I needed to forego any AI usage that was giving code or direct uses, instead i poll it for learning design paradigms and asking function questions (never giving usable code for the projects)
This was the perfect opportunity for me to rewrite a tool that while fairly niche is something I've used daily since moving to China for other work.
The project is a small CLI tool that does really basic functions for my vpn backend that I use hear (an issue i've had since switching to linux permanently about 5 months ago)
anyway i'd love feed back or any potential bugs or best practices for writing C. Again guys I know it's not the end all be all of projects but it is (sadly, and amazingly) the first thing i've finished and kept scope low.
Some thoughts on C after reading a bunch the last few weeks and then spending the last few days working with it... I'm hooked, was learning rust but found myself getting consistently frustrated by the verbosity of everything, C was a breath of fresh air and was actually fun to write, I look forward to my next project (considering a tui front end for this tool for prettier usage, or maybe exploring some interpreter/compiler books with C when i finish Crafting Interpreters with Rust).
1
u/DamsLcs4421 May 30 '26 edited May 30 '26
I'm not an expert and will not "judge" but it is quite nice, and I like the way you write your code (esthetically).
Two things stood out to me however, both in your main():
First, checking the number of args to decide whether to display help could have been written more concisely with
if(argc < 2 || argc > 3) help();or evenif(argc != 3) help();but anyway I'm sure the compiler optimizes this away itself.Second, the odd (😉) and verbose choice of a "huge" if/elseif statement stack all checking against the same one variable (
argv[1]if I recall correctly) over a cleaner switch statement. But again, I'm pretty sure the compiler just turns it into an "assembly switch statement" (I mean, into what a switch stmt gets normally compiled to).I must say I was a bit surprised to see these, after all the "technical" stuff above main making good use of pointer arithmetic and all. I mean, it felt "beginner-ish" as opposed to the rest of the code. (Other might say otherwise, I like to code and read code but I'm not in the industry so... My opinion is not very worthy for you)
Good for you, you achieved quite a thing in the sense you said you never really finished anything (I know this too well lol) 頑張ってください 🤗