Message from discussion
How to passing multidimesional array of string to function?
Received: by 10.224.177.12 with SMTP id bg12mr11614452qab.0.1343789899471;
Tue, 31 Jul 2012 19:58:19 -0700 (PDT)
Received: by 10.66.72.165 with SMTP id e5mr3115892pav.4.1343789448933;
Tue, 31 Jul 2012 19:50:48 -0700 (PDT)
Path: a15ni13561295qag.0!nntp.google.com!r1no8734551qas.0!news-out.google.com!g9ni9632822pbo.0!nntp.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nrc-news.nrc.ca!goblin1!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail
From: C3PO <nos...@nospam.com>
Newsgroups: comp.lang.c
Subject: Re: How to passing multidimesional array of string to function?
Date: Sat, 28 Jul 2012 20:41:36 +0000 (UTC)
Organization: Aioe.org NNTP Server
Lines: 32
Message-ID: <jv1iq0$aci$1@speranza.aioe.org>
References: <500d3b6c$0$17953$4fafbaef@reader1.news.tin.it>
<31cc0ad4-4814-4735-a058-dddc4303c8c8@googlegroups.com>
<jumn8h$jk1$1@dont-email.me>
NNTP-Posting-Host: fzbbCWSio2+G1BzMufGNvw.user.speranza.aioe.org
Mime-Version: 1.0
X-Complaints-To: abuse@aioe.org
X-Notice: Filtered by postfilter v. 0.8.2
Bytes: 1904
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
On Tue, 24 Jul 2012 13:50:08 -0400, Eric Sosman wrote:
> On 7/24/2012 1:21 PM, Varun Tewari wrote:
>> Eventually, its a char pointer.
>
> No: A "multidimensional array of string" might be any of a
> few different things, but "a char pointer" is not among them.
No, Varun is correct here. C pointers can be complicated so I will
explain in some detail.
First, you must understand that arrays and pointers are really the same
thing under the hood. An array is kind of like a fixed length pointer.
So "array of X" = "pointer to X", here X can be anything (except void,
where we can have a pointer to a void type but not a void array).
Now, the string type in C is char*, e.g. pointer to char. However when
people talk of "pointer to a string" they mean "pointer to a sequence of
chars terminating in the NULL byte (\000). So "pointer to string" =
"string".
Now we have:
array of string
= pointer to string
= string
= char *
Hope that helps. It took me a while to get comfortable with this stuff.
Best regards,
___ C3PO ___