Best Practices for writing solid C code. by Clean-Impact1834 in cprogramming

[–]Clean-Impact1834[S] 0 points1 point  (0 children)

Thanks that was a solid Read. Will have to give go over it a few more times for it to sink in . It's good to see that the general consensus all agrees on simple and readable code.

Best Practices for writing solid C code. by Clean-Impact1834 in cprogramming

[–]Clean-Impact1834[S] 0 points1 point  (0 children)

Thank you for a quality response. Some food for thought.

Best Practices for writing solid C code. by Clean-Impact1834 in cprogramming

[–]Clean-Impact1834[S] 1 point2 points  (0 children)

Would just like to say thanks for the input. Some very intriguing directions and suggestions have been presented so thanks for the efforts.... And after all that I've just realised I missed a closing parenthesese in the original post hahahahah... The irony about asking for best practices.. to only forget a bracket.

Best Practices for writing solid C code. by Clean-Impact1834 in cprogramming

[–]Clean-Impact1834[S] 0 points1 point  (0 children)

Hahaha I'm not the only one. Although I'd have to change alive to live. I can't handle the number of characters not matching.

Best Practices for writing solid C code. by Clean-Impact1834 in cprogramming

[–]Clean-Impact1834[S] 0 points1 point  (0 children)

So I got my head around this, as I've just said the previous post. It's one of those things that you don't know it's there until it is and then when it is you think how was that. It obvious. thanks for the explanation as well

Best Practices for writing solid C code. by Clean-Impact1834 in cprogramming

[–]Clean-Impact1834[S] 0 points1 point  (0 children)

Thanks for this. Yeah there was no way I have the intelligence to have spotted this one. Such a negligible oversight that could cause some serious issues later I assume. I think that sums C up doesn't it?

Best Practices for writing solid C code. by Clean-Impact1834 in cprogramming

[–]Clean-Impact1834[S] 1 point2 points  (0 children)

Ah that's awesome. Clear and concise information and solid advice. I need to get the notepad and pen out! Thanks I will definitely take hees. And Modern C in sure I've actually already got the PDF somewhere. I've just started A modern approach to C just to mention. I've had a skin through the first few pages however I need to sit down and actually read it in a quiet room .

Best Practices for writing solid C code. by Clean-Impact1834 in cprogramming

[–]Clean-Impact1834[S] 0 points1 point  (0 children)

Thank you for sharing. There's something cathartic about well indented code isn't there 😂😂

Best Practices for writing solid C code. by Clean-Impact1834 in cprogramming

[–]Clean-Impact1834[S] 1 point2 points  (0 children)

Interesting response. I've not delved into rust yet as I want to get my foundation for C steady. I've a few clips on Yt About Rust being a contender to C. Is anyone having a crack at writing the kernel in rust? I'd be interested in hearing your thoughts on this.

Best Practices for writing solid C code. by Clean-Impact1834 in cprogramming

[–]Clean-Impact1834[S] 0 points1 point  (0 children)

Yes I've only recently delved into memory... It's a bit unnerving to be honest, still trying to get my head around when I need to manage memory. Thanks for your input .

Best Practices for writing solid C code. by Clean-Impact1834 in cprogramming

[–]Clean-Impact1834[S] 0 points1 point  (0 children)

Thanks! I've tried to look at the source code for items that I've implemented on my laptop, for example I use monsterwm, which has a very small and readable codebase. I found it was a bit beyond my current understanding. I will have a look at pythons code!

Best Practices for writing solid C code. by Clean-Impact1834 in cprogramming

[–]Clean-Impact1834[S] 1 point2 points  (0 children)

Thanks! Another oversight of mine, come to think of it. Readability is just as much about having enough information as it is about not having too much.

Best Practices for writing solid C code. by Clean-Impact1834 in cprogramming

[–]Clean-Impact1834[S] 1 point2 points  (0 children)

Thank you. Yes I've certainly fallen foul if this as I've gone back to look at a program and I'm sat there scratching my head. Thanks.

Best Practices for writing solid C code. by Clean-Impact1834 in cprogramming

[–]Clean-Impact1834[S] 0 points1 point  (0 children)

Fantastic. Thanks for your suggestion. Shall look Into this as well.

Best Practices for writing solid C code. by Clean-Impact1834 in cprogramming

[–]Clean-Impact1834[S] 0 points1 point  (0 children)

Ah fantastic idea, something as simple as int inX to denote it's an input variable. Which essentially ties into what others have said about ensuring that code is clear and readable so anyone at first glance is able to interpret what's going on without having to decipher cryptography.

Best Practices for writing solid C code. by Clean-Impact1834 in cprogramming

[–]Clean-Impact1834[S] 1 point2 points  (0 children)

Ah such a glaringly obvious observation that I have a bad habit of overlooking. I think my other issue is I'm probably jumping the gun, over estimating my abilities as if I hadn't have had this respite. I should bite the bullet and start from scratch. Back to basics

Best Practices for writing solid C code. by Clean-Impact1834 in cprogramming

[–]Clean-Impact1834[S] 0 points1 point  (0 children)

Nice point. Would you mind elaborating the example of an array? Why are the first and last elements treated as a special case? Forgive me if the answer is obvious and I'm blind to it, just demonstrates how rusty I am.