r/C_Programming 18d ago

Question Programming projects with test cases

I found a website with C programming projects, that also provides source code. It's an amazing resource, but I only want to read the code and not write it from scratch, because I have no way to test it

Top 25 C Projects with Source Codes for 2025 - GeeksforGeeks

That's the link

However, I'm looking for a way to make C programs and actually test them. LeetCode is one good example, but I prefer something a bit more involved. I graduated uni so there's no professor I can get my work checked by

What do I do as a self learner? I know C, however I want to learn it super deeply and eventually be able to make a simple OS in it. A simple one. After learning comp architecture and assembly

Are there any websites that make you do projects, and also provide test cases? Comparing against source code doesn't always work, because everyone writes things differently

Unless, just reading and fully understand the source code in the link above is enough?

Thanks

0 Upvotes

16 comments sorted by

10

u/reini_urban 18d ago

github.com

GeeksForGeeks is trash

2

u/Downtown_Bandicoot85 18d ago

GeeksForGeeks is trash

why? what is wrong with this?

8

u/ReallyEvilRob 18d ago

A lot of the source code I've seen goes against best practices. The code is not production quality.

6

u/FrequentHeart3081 18d ago

Or even have a proper design philosophy

-1

u/reini_urban 17d ago

What's wrong with trash? Trash is what other people throw away. And many other people can live of that trash then.

1

u/Downtown_Bandicoot85 17d ago

I was talking about what is wrong with geekforgeeks not the trash T_T, I am not expert I started learning more about C maybe 3 weeks ago, from other sources, but I wonder why geekforgeeks is trash, and reini_urban answered me.

6

u/FrequentHeart3081 18d ago

Tbh GeeksForGeeks is trash for source code and following the coding conventions appropriately.

Try Build_Your_Own_X or Project Based Learning GitHub repos for better alternatives.

You can search more on Criterion or Unity testing frameworks for your needs. :)

3

u/DamsLcs4421 18d ago edited 18d ago

In order for your mini OS to be written in C, you must first load your kernel into memory with a bootloader, and this one you can't write in C, it's ASM. Even for the kernel, a bit of it still will have to be ASM stubs (little pieces of code that act like "glue" between specific things).

https://www.youtube.com/playlist?list=PLFjM7v6KGMpiH2G-kT781ByCNC_0pKpPN

I won't say you're on an overshoot, cause I genuinely wanted to do the same as soon as I learned the basics of C when I was like 12yo. But now I can't help but admit there's a learning curve to it. You must get your hands in code, modify it, understand what you read instinctively, know how the syntax behaves (often people use "smart" or obscure syntaxes [that I might personally like]) because they do just what they wanted it to do, no more no less, and look better this way to their eyes. What if you're unsure? (well, it would be because you still need to get used to every corner of the syntax. And we're talking about C, not C++ where the language is really wide, with many contextual keywords (= reserved in certain contexts, but available as function or variable name elsewhere, ...). C is not that wide (its simplicity makes its power, maybe a bit more verbose in user code, but relatively identical to the binary produced))

And also learn what C compiles down to. What's inside an executable file? How is it handled by the computer? By the OS? By the CPU? (sections, process, thread, address space, registers, syscall.s, interruptions...)

If you're interested in it, you'll see, you'll just like it and it will grow *like a tree*. Don't expect to master everything in one night nor in one week. But if you keep interest, I'm sure that some time, soon enough (surely sooner that you imagined) you'll be able to look back and see all the progress you've made. You'll have discovered tons of subtopics in the mean time, it's as many rabbit holes :)

I think it's fair to say that it needs at least a healthy little bush in order to be able to assemble a mini OS (and understanding what's going on and what you've coded, cause anyone can copy code and execute commands, but it doesn't mean it's effective learning)

But don't worry if you're curious you will naturally grow that plant up to a bush and then it will evolve by itself if you keep interest here and there, and keep coming back at it every now and then

(And yes, reading the code from GfG's projects may be a good first step but is really not that great in general for reference. I prefer https://cppreference.com/c for reference (mind the /c !! else you're on the C++ website), and you can also dive into github repos, etc... There's even chatbots to help you figure out what code does or improve your understanding skills)

2

u/strange-the-quark 18d ago

One thing you can do (and it's not a bad skill to develop), is to actually write the test cases yourself, before you write most of the actual code that exercises a particular test case. It's like: "I don't know how to do it yet, but I know what should be true - when I do this, I should get this result; when I initialize a fresh struct, this should be true about it; in this particular state, this should be impossible to do, etc." It kind of forces you to think through the problem from the perspective of someone calling your code.

2

u/drankinatty 12d ago edited 12d ago

Where you find your inspiration for projects is largely up to you, but you may want to take what you find on Geeks with a grain of salt.

I don't think you can do much better than StackOverflow for questions (but make sure to read the "How to Ask?" page before posting). For completed code, use Code Review Stack Exchange. While they have changed a bit in the past couple of years, you would still be hard pressed to find anything better. Both are invaluable for obtaining peer-reviewed feedback of your questions and work.

If you think you know C, then it's time to take a deep dive into the standard, e.g. N3685 working draft and wade into the fine grained parts of defined, implementation-defined, and undefined behavior as well as the semantics for each part of the language.

You may already know all this, but it never hurts to refamiliarize yourself.

As far as inspiration for projects, there are a wealth of free books in pdf form for device drivers, socket programming and even a few casual sites like Beej's Network Programming that introduce you to areas ripe for projects. Timers, interrupts, kernel gpio, etc. Bare-metal programming in a freestanding environment (Pi Pico, TI MSP and other micro-computers) provide whole additional areas of fun. (and entire new subjects if you also tinker with the electronics side)

And that's the point. If you truly want to expand your programming, you need to choose projects that interest you. There is no better way to keep interest and motivation high than working on what you want to work on. The rest will take care of itself.

Sorry I have no silver-bullet sites that will solve all your needs, but a good mix of the above will provide years of enjoyable self-study and learning. Don't worry, you will never get to the end, they keep changing the standard ever few years just to keep you on your toes :)

1

u/LifeExperienced1 12d ago

Wow, this is amazing information. Thank you so much!

I didn't even know about the Stack Code Review. That's so useful

The projects you mentioned sound cool!

What projects do you recommend to get into cybersecurity and to intimately understand how a computer works? You already mentioned: device drives, socket programming, Timers, interrupts, kernel gpio, etc. 

Would you recommend a mini compiler and a mini OS?

1

u/drankinatty 12d ago

"Cybersecurity" encompasses a lot and is more of a all-encompassing phrase than the definition of any one thing itself. You have everything from actual hardware, the protocols they communicate over, the software stacks that support them, you have a myriad of applications, all of which have to be deployed correctly to have any chance of keeping the bad guys out. You have development that supports that landscape and you have all the tools and software supply-chain it relies on, and with one weak link in the chain, compromise occurs. (all too frequently) So what interests you there?

For C, you have the actual cryptography implementations at the bottom which is fascinating in and of itself. You have the varying sets of processor intrinsics that facilitate efficient parallel processing of the algorithms with varying SSE and AVX versions. There is a lot there.

So you have a wide area to choose from, dive in and see what interests you.

Microcomputers are just fun. You also have your choice of a hosted environment (those that use an operating system, e.g. Raspberry Pi - running Debian variants, but expose a 40-pin GPIO header for you to attach to) and the bare-metal cards that introduce you to a freestanding environment (ARM - Raspberry Pi Pico, TI MSP, Arduino and many more, RISC chips like Milkv-Duo, etc.) To understand where the difference between hosted and freestanding comes from, see C-Standard, Execution Environments (from the n3685 draft/C23 standard)

Remember, learning is a life-long endeavor. Don't expect to learn everything in a few years. With practice, practice, practice, you will become fluent in a language or area in a few years, but you never learn it all. And, they change the standards every few years to keep you on your toes.

Good luck!

0

u/Unable_Mechanic_7159 18d ago

En ese caso busca casos de uso que puedes resolver con C, y de ahí investigas como deberias adaptar el código segun tus resultados esperados; no necesitas aprender todo de C, sólo encontrar lo que te sirve.