Pass struct by reference in C

后端 未结 5 668
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-13 02:28

Is this code correct? It runs as expected, but is this code correctly using the pointers and dot notation for the struct?

struct someStruct {
 unsigned int t         


        
5条回答
  •  渐次进展
    2020-12-13 02:46

    Yes, its correct usage of structures. You can also use

    typedef struct someStruct {
     unsigned int total;
    } someStruct;
    

    Then you won't have to write struct someStruct s; again and again but can use someStruct s; then.

提交回复
热议问题