in reply to Re: Inline::C demonstration for C programmers
in thread Inline::C demonstration for C programmers
Actually, they are guaranteed to exist. According to ISO C99 TC3 (PDF) section 6.4.5 #5, string literals (e.g. "foo", the ones in inflect()) initialize arrays with static storage duration. According to 6.2.4 #3, objects with static storage duration have a lifetime which is "the entire execution of the program".
The strings in inflect() are not only guaranteed to exist after the function's block is left, they are guaranteed to exist before the first time the function executes (5.1.2 #1).
In other words, that code is safe. :)
Updated: to sound a little less hostile
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Inline::C demonstration for C programmers
by ikegami (Patriarch) on Sep 01, 2008 at 23:14 UTC | |
by missingthepoint (Friar) on Sep 03, 2008 at 02:07 UTC |