How to redo the same code using structs

Home Forums C Programming How to redo the same code using structs

This topic contains 3 replies, has 2 voices, and was last updated by  GWILouisaxwzkla 8 years, 4 months ago.

  • Author
    Posts
  • #2216

    I have this project that i need to redo the exact same way, but using structs. I can get as far as creating the structs with the fields, however, I am having difficulty getting started, I don’t quite have down the concept, or at least i’m having trouble ‘wrapping’ my head around the concept, i just can’t seem to get started; past the declaration.

    any help would be appreciated. Thanks

  • #3596

    You really just need to group all your data together ( structs are handy for this purpose ). So if you have a function prototype like:

    change it to:

    when you need to access a member of the struct , just use the dot operator and use the data as usual:

    not too much to the conversion …….

  • #3597

    Thank you!

  • #3598

    A little correction. It seems you are passing arrays of names , id’s and crn into the function:

    so you would change your prototype to :

    and access the data members like this:

    my bad ………

You must be logged in to reply to this topic.

0 Shares
Share
+1
Tweet
Share
Stumble