??? 10/05/11 07:59 Modified: 10/05/11 08:03 Read: times |
#184042 - That's the key! Responding to: ???'s previous message |
Neil Kurzman said:
It returns a pointer to on on the items. That is the key point that the authors are making in this example! K&R said:
Consider the problem of writing a function month_name(n), which returns a pointer to a character string ... This is an ideal application for an internal 'static' array. So the array has to be 'static' so that the data is still there when the function returns, and the pointer returned remains valid. |
Topic | Author | Date |
Another static question... | 01/01/70 00:00 | |
WIthout Static In This Case | 01/01/70 00:00 | |
Thank you | 01/01/70 00:00 | |
It is worse than that | 01/01/70 00:00 | |
could add 'const' | 01/01/70 00:00 | |
That's the key! | 01/01/70 00:00 | |
Thanks Neil | 01/01/70 00:00 | |
True - but not quite the point here | 01/01/70 00:00 | |
isn't it explained in the book itself? | 01/01/70 00:00 | |
Yes, it is | 01/01/70 00:00 | |
Yes, but... | 01/01/70 00:00 | |
If the pupil does not understand... | 01/01/70 00:00 | |
In this instance... | 01/01/70 00:00 | |
That is why the call it learning. | 01/01/70 00:00 | |
isn't this just another example of .... | 01/01/70 00:00 | |
Information-hiding | 01/01/70 00:00 | |
not arguing that part | 01/01/70 00:00 | |
Not just protection. Also better overview (and reuse) | 01/01/70 00:00 |