How to structure a C program effectively

后端 未结 7 1327
独厮守ぢ
独厮守ぢ 2020-12-24 12:01

Let me first say that I\'ve got a fair amount of experience in both C and C++. However, I\'m starting a new project in C and I\'ve been working in object-oriented languages

相关标签:
7条回答
  • 2020-12-24 12:45

    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:

    • use typedefs with struct definitions so you don't need to scatter the 'struct' keyword throughout the code
    • only use casts when they are actually needed - the cast on the return value from malloc() is unecessary
    0 讨论(0)
提交回复
热议问题