Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   kandr2 question (http://www.velocityreviews.com/forums/t954062-kandr2-question.html)

tom st denis 10-30-2012 09:48 PM

Re: kandr2 question
 
On Oct 30, 5:41*pm, "Bill Cunningham" <nos...@nspam.invalid> wrote:
> * * 1.9 page 29 has this function.
>
> int getline (char s[], int lim)
>
> Unless I'm missing something here to pass an array shoudn't that first
> parameter be char *s ?
>
> Bill


**** off.

tom st denis 10-30-2012 09:56 PM

Re: kandr2 question
 
On Oct 30, 5:50*pm, "Bill Cunningham" <nos...@nspam.invalid> wrote:
> tom st denis wrote:
> > **** off.

>
> * * Go **** yourself. That's what I have been told.


If you don't know that char s[] is equivalent to char *s by now you
have to be trolling and are deserving of contempt.

And frankly I don't get you. Trolling comp.lang.c? Do you know how
specific that is? Of the few 100,000 people on the planet who are
aware of C you have to be one of the trolls? Seriously? Get a hobby.

Keith Thompson 10-30-2012 10:00 PM

Re: kandr2 question
 
"Bill Cunningham" <nospam@nspam.invalid> writes:
> §1.9 page 29 has this function.
>
> int getline (char s[], int lim)
>
> Unless I'm missing something here to pass an array shoudn't that first
> parameter be char *s ?


N1570 6.7.6.3p7.

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

Keith Thompson 10-30-2012 10:01 PM

Re: kandr2 question
 
tom st denis <tom@iahu.ca> writes:
[...]
> ... char s[] is equivalent to char *s ...


As you know, the equivalence applies only for function parameters.

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

tom st denis 10-30-2012 10:07 PM

Re: kandr2 question
 
On Oct 30, 6:04*pm, "Bill Cunningham" <nos...@nspam.invalid> wrote:
> tom st denis wrote:
> > If you don't know that char s[] is equivalent to char *s by now you
> > have to be trolling and are deserving of contempt.

>
> * * Of course I know that Dick. What's that got to do with anything? Read
> the standard.


And you wrote...

>int getline (char s[], int lim)
>
>Unless I'm missing something here to pass an array shoudn't that first
>parameter be char *s ?


And I wrote "they're equivalent."

So maybe yes it should be char *s out of convention but char s[] is
allowed there as for function parameters they're equivalent.

And since clearly you seem to know this [judging by your reply here]
why the **** are you asking?

Tom

tom st denis 10-30-2012 10:07 PM

Re: kandr2 question
 
On Oct 30, 6:01*pm, Keith Thompson <ks...@mib.org> wrote:
> tom st denis <t...@iahu.ca> writes:
> [...]
>
> > * * * * * * * * * *... char s[] is equivalent to char *s ...

>
> As you know, the equivalence applies only for function parameters.


Yup, but I was replying in context to his original question so the
pedantic police need not apply.

Tom

BartC 10-30-2012 10:08 PM

Re: kandr2 question
 


"tom st denis" <tom@iahu.ca> wrote in message
news:3f556c91-92ab-4d83-96d2-7d7952a356ee@s18g2000yqh.googlegroups.com...
> On Oct 30, 5:50 pm, "Bill Cunningham" <nos...@nspam.invalid> wrote:


>> That's what I have been told.

>
> If you don't know that char s[] is equivalent to char *s by now you
> have to be trolling and are deserving of contempt.


But in certain contexts, they are not the same. The question is reasonable.

--
Bartc


tom st denis 10-30-2012 10:10 PM

Re: kandr2 question
 
On Oct 30, 6:07*pm, "Bill Cunningham" <nos...@nspam.invalid> wrote:
> tom st denis wrote:
> > If you don't know that char s[] is equivalent to char *s by now you
> > have to be trolling and are deserving of contempt.

>
> * * And you should know Prick that char s[] and char *s *are not* equivalent
> always.


They are in the context of the question you asked. Of course I wasn't
answering a question you didn't ask. That should go without saying.

Tom

tom st denis 10-30-2012 10:11 PM

Re: kandr2 question
 
On Oct 30, 6:08*pm, "BartC" <b...@freeuk.com> wrote:
> "tom st denis" <t...@iahu.ca> wrote in messagenews:3f556c91-92ab-4d83-96d2-7d7952a356ee@s18g2000yqh.googlegroups.com...
>
> > On Oct 30, 5:50 pm, "Bill Cunningham" <nos...@nspam.invalid> wrote:
> >> * That's what I have been told.

>
> > If you don't know that char s[] is equivalent to char *s by now you
> > have to be trolling and are deserving of contempt.

>
> But in certain contexts, they are not the same. The question is reasonable.


As a function parameter? They're entirely interchangeable. It's
convention to use the star but you can use [] if it floats your boat.

Tom

tom st denis 10-30-2012 10:13 PM

Re: kandr2 question
 
On Oct 30, 6:09*pm, "Bill Cunningham" <nos...@nspam.invalid> wrote:
> tom st denis wrote:
> > And since clearly you seem to know this [judging by your reply here]
> > why the **** are you asking?

>
> None of your God Damn Business and *I* was right. But that's not my point..


Right about what? It doesn't have to be "char *s" it CAN be "char
s[]" and be perfectly valid code [when used as a parameter to a
function].

It's convention to use the star but that's not mandatory. Just like
you could write

char a[4];

a[3] = 4;

Or

3[a] = 4;

They're equivalent C code. Most people would use the former instead
of the latter even though they have the same effect.

Tom


All times are GMT. The time now is 01:52 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.