kandr2 question

T

tom st denis

    §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.
 
T

tom st denis

    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.
 
K

Keith Thompson

Bill Cunningham said:
§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.
 
T

tom st denis

tom said:
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
 
T

tom st denis

                   ... 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
 
B

BartC

tom st denis said:
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.
 
T

tom st denis

tom said:
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
 
T

tom st denis

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
 
T

tom st denis

tom said:
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
 
T

tom st denis

    You Obviously didn't understand the original question in you infinite
mind. Dick.

You asked if a char s[] inside a parameter list should instead be char
*s.

The answer is no. It doesn't have to be.

You only wrote one question in your original post. Unless you have
some sort of vanishing NNTP ink that I don't know of I think saw and
answered your original question.

Tom
 
T

tom st denis

You asked if a char s[] inside a parameter list should instead be char
*s.
The answer is no.  It doesn't have to be.

[snip]

I have never seen good function prototypes except these examples declare an
array definition as char s[] in the prototype. Are you looking at a babie's
code? They must be writing like this is kandr2 to simplify things.

I've seen it before, like I said I too don't use it, but it's valid C
code [even in C11] so the answer [again] to your original question is
no, it doesn't HAVE to be "char *s" in the parameter list.

Tom
 
K

Keith Thompson

tom st denis said:
                   ... 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.

Nevertheless, I was concerned that other readers might not pay
sufficient attention to the context.
 
K

Keith Thompson

Bill Cunningham said:
tom said:
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.

Will *both* of you please calm the &^%$ down?
 
T

tom st denis

tom st denis said:
[...]
                   ... char s[] is equivalent tochar *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.

Nevertheless, I was concerned that other readers might not pay
sufficient attention to the context.

Fair enough.

Tom
 
J

James Kuyper

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.

No - as he said, they're different only "in certain contexts". The fact
that there are contexts where it does make a difference, means that it's
not unreasonable for a newbie to be unaware of their equivalence in this
context.

It is, of course, completely unreasonable for someone like Bill
Cunningham, who has been "learning" C for more than a decade, and should
therefore have long since ceased being a newbie, to be unaware of this fact.
 
T

tom st denis

Bill Cunningham said:
tom said:
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.

Will *both* of you please calm the &^%$ down?

I dunno, caught a nerve today with usenet trolls... I should just go
out for a pint...
 
B

Bill Cunningham

§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
 
T

tom st denis

tom said:
It's convention to use the star but that's not mandatory.  Just like
you could write
char a[4];
a[3] = 4;

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.

In my original question I was asking about convention.

No you didn't. Here's your original question
Unless I'm missing something here to pass an array shoudn't that first
parameter be char *s ?

And the answer is no. It's not an error, it can be "char s[]" if the
author wants to write that way.

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top