C concepts

Can anybody tell me what is the advantage of using the below C concepts in embeddded systems (application wise)

  1. pointers
  2. Function pointers
  3. structure
  4. union
  5. structure pointer
  6. pointer to pointer
  7. Array of structures
  8. pointers and arrays

Please help me with the above question

Hello prashanth_92!

  1. , 6) , 8) Passing a large object by reference is equivalent to just passing along a plain old number. You can manipulate the needed parts directly as opposed to copying an object, altering it, then passing back the copy to be put in place of the original.

  2. Pointers to functions allows you to select any component of your logic at runtime. If you choose to hardcode the function then at runtime you can only choose a particular function in your program.

  3. Structures prove their usefulness in Object Oriented Programming which comes in handy many a times while solving problems in real life.

  4. To learn more about unions and why they are useful check out this link

  5. You use a pointer to a structure as a funciton arguiment rather than the structure itself to a) let the called function modify the variable in the calling function, b) avoid making a copy of the struct variable. Making copies takes time and if the struct is large, it eats memory. Copies also involve considerations of “deep copy” versus “shallow copy”.

  6. A single array of structures can be used in place of several arrays of regular variables. Saving a bit of memory.

Happy programming! :slight_smile: