kandr2 question

Discussion in 'C Programming' started by tom st denis, Oct 30, 2012.

  1. tom st denis

    tom st denis Guest

    On Oct 30, 5:41 pm, "Bill Cunningham" <> 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, Oct 30, 2012
    #1
    1. Advertising

  2. tom st denis

    tom st denis Guest

    On Oct 30, 5:50 pm, "Bill Cunningham" <> 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.
     
    tom st denis, Oct 30, 2012
    #2
    1. Advertising

  3. "Bill Cunningham" <> 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) <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, Oct 30, 2012
    #3
  4. tom st denis <> writes:
    [...]
    > ... char s[] is equivalent to char *s ...


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

    --
    Keith Thompson (The_Other_Keith) <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, Oct 30, 2012
    #4
  5. tom st denis

    tom st denis Guest

    On Oct 30, 6:04 pm, "Bill Cunningham" <> 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, Oct 30, 2012
    #5
  6. tom st denis

    tom st denis Guest

    On Oct 30, 6:01 pm, Keith Thompson <> wrote:
    > tom st denis <> 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
     
    tom st denis, Oct 30, 2012
    #6
  7. tom st denis

    BartC Guest

    "tom st denis" <> wrote in message
    news:...
    > On Oct 30, 5:50 pm, "Bill Cunningham" <> 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
     
    BartC, Oct 30, 2012
    #7
  8. tom st denis

    tom st denis Guest

    On Oct 30, 6:07 pm, "Bill Cunningham" <> 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, Oct 30, 2012
    #8
  9. tom st denis

    tom st denis Guest

    On Oct 30, 6:08 pm, "BartC" <> wrote:
    > "tom st denis" <> wrote in messagenews:...
    >
    > > On Oct 30, 5:50 pm, "Bill Cunningham" <> 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, Oct 30, 2012
    #9
  10. tom st denis

    tom st denis Guest

    On Oct 30, 6:09 pm, "Bill Cunningham" <> 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
     
    tom st denis, Oct 30, 2012
    #10
  11. tom st denis

    tom st denis Guest

    On Oct 30, 6:12 pm, "Bill Cunningham" <> wrote:
    > tom st denis wrote:
    > > Yup, but I was replying in context to his original question so the
    > > pedantic police need not apply.

    >
    >     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
     
    tom st denis, Oct 30, 2012
    #11
  12. tom st denis

    tom st denis Guest

    On Oct 30, 6:25 pm, "Bill Cunningham" <> wrote:
    > tom st denis wrote:
    > > On Oct 30, 6:12 pm, "Bill Cunningham" <> wrote:
    > >> tom st denis wrote:
    > >>> Yup, but I was replying in context to his original question so the
    > >>> pedantic police need not apply.

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

    >
    > [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
     
    tom st denis, Oct 30, 2012
    #12
  13. tom st denis <> writes:
    > On Oct 30, 6:01 pm, Keith Thompson <> wrote:
    >> tom st denis <> 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.


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

    --
    Keith Thompson (The_Other_Keith) <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, Oct 30, 2012
    #13
  14. "Bill Cunningham" <> writes:
    > 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.


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

    --
    Keith Thompson (The_Other_Keith) <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, Oct 30, 2012
    #14
  15. tom st denis

    tom st denis Guest

    On Oct 30, 6:30 pm, Keith Thompson <> wrote:
    > tom st denis <> writes:
    >
    > > On Oct 30, 6:01 pm, Keith Thompson <> wrote:
    > >> tom st denis <> writes:
    > >> [...]

    >
    > >> >                    ... 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
     
    tom st denis, Oct 30, 2012
    #15
  16. tom st denis

    James Kuyper Guest

    On 10/30/2012 06:11 PM, tom st denis wrote:
    > On Oct 30, 6:08�pm, "BartC" <> wrote:
    >> "tom st denis" <> wrote in messagenews:...

    ....
    >>> 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.
    --
    James Kuyper
     
    James Kuyper, Oct 30, 2012
    #16
  17. tom st denis

    tom st denis Guest

    On Oct 30, 6:31 pm, Keith Thompson <> wrote:
    > "Bill Cunningham" <> writes:
    > > 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.

    >
    > 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...
     
    tom st denis, Oct 30, 2012
    #17
  18. §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
     
    Bill Cunningham, Oct 30, 2012
    #18
  19. tom st denis wrote:

    > **** off.


    Go **** yourself. That's what I have been told.
     
    Bill Cunningham, Oct 30, 2012
    #19
  20. tom st denis

    tom st denis Guest

    On Oct 30, 6:30 pm, "Bill Cunningham" <> wrote:
    > tom st denis wrote:
    > > 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

    >
    > 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
     
    tom st denis, Oct 30, 2012
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sean
    Replies:
    1
    Views:
    605
    Cowboy \(Gregory A. Beamer\)
    Oct 20, 2003
  2. =?Utf-8?B?UnlhbiBTbWl0aA==?=

    Quick Question - Newby Question

    =?Utf-8?B?UnlhbiBTbWl0aA==?=, Feb 14, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    670
    Iain Norman
    Feb 16, 2005
  3. =?Utf-8?B?YW5kcmV3MDA3?=

    question row filter (more of sql query question)

    =?Utf-8?B?YW5kcmV3MDA3?=, Oct 5, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    955
    Scott Allen
    Oct 6, 2005
  4. Philip Meyer
    Replies:
    0
    Views:
    430
    Philip Meyer
    Nov 30, 2003
  5. Bit Byte
    Replies:
    1
    Views:
    865
    Teemu Keiski
    Jan 28, 2007
Loading...

Share This Page