sci <sci998@yahoo.com> scribbled the following:[color=blue]
> Joona I Palaste <palaste@cc.helsinki.fi> wrote in message
> news:bm1gqj$ep3$1@oravannahka.helsinki.fi...[color=green]
>> sci <sci998@yahoo.com> scribbled the following:[color=darkred]
>> > I believe both ways to create an array of strings are correct. Is there[/color][/color]
> any[color=green][color=darkred]
>> > difference between these two?[/color]
>>[color=darkred]
>> > 1. char *MyString[30] = {"First string", "Second string", ..."Tenth
>> > string"};[/color]
>>[color=darkred]
>> > 2. char MyString[10][30] = {"First string", "Second string", ..."Tenth
>> > string"};[/color][/color][/color]
[color=blue][color=green]
>> ii) The strings in (2) are guaranteed to be modifiable. The strings in
>> (1) are not.[/color][/color]
[color=blue]
> Why strings in (1) are not modifiable?[/color]
They *can* be. They just aren't *guaranteed* to be. The C standard
allows the implementation to place them in unmodifiable memory.
[color=blue][color=green]
>> iii) You can safely return the strings from (1) as function return
>> values, they're always in scope. You can't do that for the strings
>> from (2) as they are only in scope when MyString is.[/color][/color]
[color=blue]
> Why you can return strings from (1)? Are you talking about returning the
> whole "array of strings" in (1) or just one of the strings?[/color]
Just one of the strings. For example, return MyString[0]; is a
sensible thing to do in case (1) but not in case (2). But return
MyString; is not sensible in either case.
[color=blue]
> Thanks for your help![/color]
You're welcome.
--
/-- Joona Palaste (palaste@cc.helsinki.fi) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
|
http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"You could take his life and..."
- Mirja Tolsa