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

Viewing 3 reply threads
  • Author
    Posts
    • #2216
      MaricruDeluca
      Participant

      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
      GWILouisaxwzkla
      Participant

      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
      MaricruDeluca
      Participant

      Thank you!

    • #3598
      GWILouisaxwzkla
      Participant

      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 ………

Viewing 3 reply threads
  • The forum ‘C Programming’ is closed to new topics and replies.