Timeline for Passing an array of structs to a function?
Current License: CC BY-SA 3.0
16 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Dec 28, 2014 at 18:36 | comment | added | Igor | @iharob Yes, I will 'accept' the answer which helped me the most, as soon as possible. Right now I am evaluating/implementing all solutions in the program I am writing. The original question was just greatly simplified real life case | |
| Dec 28, 2014 at 7:09 | comment | added | Iharob Al Asimi | @Igor You can accept the answer that helped you the most. Check this link. | |
| Dec 28, 2014 at 7:06 | comment | added | Igor | @user3386109, (at)iharob, (at)DavidC.Rankin tnx++ to all of you. I learned a lot from your comment's thread above | |
| Dec 28, 2014 at 5:22 | comment | added | user3386109 |
@DavidC.Rankin Agreed that static serves no purpose for an array of 12 items in code targeted for a modern desktop machine.
|
|
| Dec 28, 2014 at 5:16 | history | edited | Iharob Al Asimi | CC BY-SA 3.0 |
added 84 characters in body
|
| Dec 28, 2014 at 5:14 | comment | added | David C. Rankin |
I stand corrected regarding the static within a block. The use of the the static in main() serves no purpose here.
|
|
| Dec 28, 2014 at 5:10 | history | edited | Iharob Al Asimi | CC BY-SA 3.0 |
added 1800 characters in body
|
| Dec 28, 2014 at 5:09 | comment | added | user3386109 |
@DavidC.Rankin When used inside of a function, the static keyword doesn't give a variable file scope, it gives the variable static storage. In other words, the variable is stored in the BSS area, and not on the stack. You can't access c[12] outside of main, unless main gives you a pointer to it.
|
|
| Dec 28, 2014 at 5:04 | comment | added | David C. Rankin |
@user3386109 - No. Giving HEAD file scope serves no purpose here. You might as well remove the address arguments from the functions. However, remove static completely so HEAD has functions scope in main() then it makes sense.
|
|
| Dec 28, 2014 at 5:03 | comment | added | user3386109 | No problem, the wording in the question made it hard to keep track of all the functions, but your answer is good +1. | |
| Dec 28, 2014 at 4:59 | comment | added | Iharob Al Asimi | @user3386109 you are right, I just re-read the question, some times I have trouble to understand english. | |
| Dec 28, 2014 at 4:58 | comment | added | user3386109 |
@DavidC.Rankin Are you confusing static with const?
|
|
| Dec 28, 2014 at 4:56 | comment | added | user3386109 |
I think OP wants the for loop inside of passByReference_inner. Doesn't really change the essence of the answer, but needs a little rearranging.
|
|
| Dec 28, 2014 at 4:55 | comment | added | David C. Rankin |
Why would you make HEAD static if you a passing by reference?
|
|
| Dec 28, 2014 at 4:43 | history | edited | Iharob Al Asimi | CC BY-SA 3.0 |
edited body
|
| Dec 28, 2014 at 4:36 | history | answered | Iharob Al Asimi | CC BY-SA 3.0 |