A 'C' program is divided into six sections: Documentation, Link, Definition, Global Declaration, Main() Function, Subprograms. While the main section is compulsory, the rest are optional in the structure of the C program.
Begin with solving basic level logical questions, and while solving always follow the best approach and best practices. Show activity on this post. A really good way to exercise C is to read (or reread) The C Programming Language (K&R) and to do every exercise at the end of each chapter.
Description. Efficient C/C++ Programming describes a practical, real-world approach to efficient C/C++ programming. Topics covered range from how to save storage using a restricted character set and how to speed up access to records by employing hash coding and caching.
This is quite a normal and sensible practice. But try not to expose the struct layout in header files, so that you have some flexibility in how it's implemented and manage your dependencies better.
See Opaque pointer for more details.
What you are suggesting is the way I always wrote C programs back in the days when I did such a thing. I don't think it is "poor mans OO", I think it is sensible procedural programming practice.
I would observe a couple of things about your C code:
Hmmm... We used to just use naming conventions... Ergo: str* does stuff with what common datastructure? So maybe just take the C# syntax and s/./_/g?
... and there ain't no inheritance ...
But look on the bright side... you can use pointer-to-pointer-to-pointer-to-function-returning-a-pointer-to-pointer-int! Oh the joy!
My bestest advise is to learn the lessons of Java (and by inference C#) and structure your libraries to NOT have side-effects... more typdefs == less headaches... and if your work-out how to follow this sage advise please let me know ;-)
Cheers. Keith.
That's a pretty reasonable way to write a C program. There is another large application out there, which does pretty much the same stuff - called the Linux kernel. Some nearly OO-features used in there:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With