It is preferred to pass pointer to structure to a function in C -


In general, to avoid copying during a function call, like to pass the structure of the pointer to a function in C is done. Its unwanted side effect is that the function function can modify the structure elements inadvertently. What is a good programming practice to avoid such errors without compromising the efficiency of the function call?

has an obvious-to-parent answer explicitly

  void Foo (const struct some_struct * p)  

This will prevent you from modifying members immediately Strat is unknowingly the same for the const .

In fact, your question looks like a copy-paste from the card, which has the expected answer to be const


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -