why do the following crash

Discussion in 'C Programming' started by parag_paul@hotmail.com, Mar 31, 2008.

  1. Guest

    File1.c

    int arr[80];

    File2.c

    extern int *arr;
    int main()
    {
    arr[1] = 100;
    return 0;
    }
     
    , Mar 31, 2008
    #1
    1. Advertising

  2. wrote:
    > File1.c
    >
    > int arr[80];
    >
    > File2.c
    >
    > extern int *arr;
    > int main()
    > {
    > arr[1] = 100;
    > return 0;
    > }


    Did you read the FAQ? You have just asked question 6.1, and if you go to
    http://c-faq.com/ you will get your answer.

    Philip
     
    Philip Potter, Mar 31, 2008
    #2
    1. Advertising

  3. Richard Guest

    Philip Potter <> writes:

    > wrote:
    >> File1.c
    >>
    >> int arr[80];
    >>
    >> File2.c
    >>
    >> extern int *arr;
    >> int main()
    >> {
    >> arr[1] = 100;
    >> return 0;
    >> }

    >
    > Did you read the FAQ? You have just asked question 6.1, and if you go
    > to http://c-faq.com/ you will get your answer.
    >
    > Philip


    Will you be replying to every question here with a pointer to the FAQ?

    If so possibly you would like to just automate your replies?

    Hint : not every programmer that comes here can memorise the entire FAQ
    nor can they always find the necessary section of the FAQ.
     
    Richard, Mar 31, 2008
    #3
  4. Ed Prochak Guest

    On Mar 31, 8:56 am, Richard <> wrote:
    > Philip Potter <> writes:
    > > wrote:
    > >> File1.c

    >
    > >> int arr[80];

    >
    > >> File2.c

    >
    > >> extern int *arr;
    > >> int main()
    > >> {
    > >> arr[1] = 100;
    > >> return 0;
    > >> }

    >
    > > Did you read the FAQ? You have just asked question 6.1, and if you go
    > > tohttp://c-faq.com/you will get your answer.

    >
    > > Philip

    >
    > Will you be replying to every question here with a pointer to the FAQ?


    Why shouldn't he, if the question really is a FAQ?

    >
    > If so possibly you would like to just automate your replies?


    Are you offering to do it? While the scope of the problem is more
    limited, the problem of interpreting human language automatically
    appears to be intractable.
    >
    > Hint : not every programmer that comes here can memorise the entire FAQ
    > nor can they always find the necessary section of the FAQ.


    The FAQ is a nice reference. No one is expected to memorize it but it
    would do good to read it once in a while. (I think I am due for a
    refresher.)
    Ed
     
    Ed Prochak, Mar 31, 2008
    #4
  5. Richard Guest

    Ed Prochak <> writes:

    > On Mar 31, 8:56 am, Richard <> wrote:
    >> Philip Potter <> writes:
    >> > wrote:
    >> >> File1.c

    >>
    >> >> int arr[80];

    >>
    >> >> File2.c

    >>
    >> >> extern int *arr;
    >> >> int main()
    >> >> {
    >> >> arr[1] = 100;
    >> >> return 0;
    >> >> }

    >>
    >> > Did you read the FAQ? You have just asked question 6.1, and if you go
    >> > tohttp://c-faq.com/you will get your answer.

    >>
    >> > Philip

    >>
    >> Will you be replying to every question here with a pointer to the FAQ?

    >
    > Why shouldn't he, if the question really is a FAQ?


    No problem if you take the time to answer too IMO.

    >
    >>
    >> If so possibly you would like to just automate your replies?

    >
    > Are you offering to do it? While the scope of the problem is more
    > limited, the problem of interpreting human language automatically
    > appears to be intractable.


    I agree.

    But a naive solution would be simply auto reply to each new post

    "have you read the FAQ : here ..."

    >>
    >> Hint : not every programmer that comes here can memorise the entire FAQ
    >> nor can they always find the necessary section of the FAQ.

    >
    > The FAQ is a nice reference. No one is expected to memorize it but it
    > would do good to read it once in a while. (I think I am due for a
    > refresher.)
    > Ed


    Off you go then. No one is stopping you. I have too. It doesn't mean I
    dont find it easier and more social to ask a human being.

    In your haste you seem to have misunderstood. My point is that 99.99% of
    questions here are answered in one way or other by the FAQ,

    Simply questioning people as to whether they read it and then somewhat
    pompously pointing them there makes the group pretty much redundant.

    By ALL means post a link to the FAQ, but add some personal explanation
    too.
     
    Richard, Mar 31, 2008
    #5
  6. Morris Dovey Guest

    Richard wrote:

    > Will you be replying to every question here with a pointer to the FAQ?
    >
    > If so possibly you would like to just automate your replies?


    Richard, I think you just had a great idea!

    > Hint : not every programmer that comes here can memorise the entire FAQ
    > nor can they always find the necessary section of the FAQ.


    That's true. Lacking automated response software, it's good to
    have folks like Philip around to help people find ready-made,
    accurate answers.

    About your automated response idea - care to take a try at it? It
    could be an interesting project!

    --
    Morris Dovey
    DeSoto Solar
    DeSoto, Iowa USA
    http://www.iedu.com/DeSoto/
     
    Morris Dovey, Mar 31, 2008
    #6
  7. Noob Guest

    Noob, Mar 31, 2008
    #7
  8. Willem Guest

    Richard wrote:
    ) But a naive solution would be simply auto reply to each new post
    )
    ) "have you read the FAQ : here ..."

    He pointed to a *specific item* in the FAQ.

    ) In your haste you seem to have misunderstood. My point is that 99.99% of
    ) questions here are answered in one way or other by the FAQ,
    )
    ) Simply questioning people as to whether they read it and then somewhat
    ) pompously pointing them there makes the group pretty much redundant.

    He pointed to the *specific part* of the FAQ that answered the question.


    SaSW, Willem
    --
    Disclaimer: I am in no way responsible for any of the statements
    made in the above text. For all I know I might be
    drugged or something..
    No I'm not paranoid. You all think I'm paranoid, don't you !
    #EOT
     
    Willem, Mar 31, 2008
    #8
  9. In article <>,
    Willem <> wrote:
    >Richard wrote:
    >) But a naive solution would be simply auto reply to each new post
    >)
    >) "have you read the FAQ : here ..."
    >
    >He pointed to a *specific item* in the FAQ.


    Yes. We all understand that.

    >) In your haste you seem to have misunderstood. My point is that 99.99% of
    >) questions here are answered in one way or other by the FAQ,
    >)
    >) Simply questioning people as to whether they read it and then somewhat
    >) pompously pointing them there makes the group pretty much redundant.
    >
    >He pointed to the *specific part* of the FAQ that answered the question.


    Yes. We all understand that.

    And, yes, all also understand that that is the part that would be a
    little tricky about implementing the auto-responder. Save that for
    Version 2.0.

    In the meantime, an auto-responder that simply greets every new thread
    (by a newbie - the program would keep a list of people to exclude from
    treatment) with "The answer is in the FAQ. Please see the FAQ at: <URL>"
    would be very nice and save certain people (e.g., Bwian) from having to
    do it manually.
     
    Kenny McCormack, Mar 31, 2008
    #9
  10. Bartc Guest

    <> wrote in message
    news:...
    > File1.c
    >
    > int arr[80];
    >
    > File2.c
    >
    > extern int *arr;
    > int main()
    > {
    > arr[1] = 100;
    > return 0;
    > }


    The declarations for the arr variable don't match.

    Try extern int arr[80] in File2.c.

    (I know arrays and pointers are /supposed/ to be interchangeable. But there
    is a subtle difference between: int a[80] and int *a)

    --
    Bart
     
    Bartc, Mar 31, 2008
    #10
  11. Bartc wrote:
    > <> wrote in message
    > news:...
    >> File1.c
    >>
    >> int arr[80];
    >>
    >> File2.c
    >>
    >> extern int *arr;
    >> int main()
    >> {
    >> arr[1] = 100;
    >> return 0;
    >> }

    >
    > The declarations for the arr variable don't match.
    >
    > Try extern int arr[80] in File2.c.
    >
    > (I know arrays and pointers are /supposed/ to be interchangeable. But there
    > is a subtle difference between: int a[80] and int *a)


    Arrays and pointers aren't supposed to be interchangable. They don't
    represent the same concept.

    An array of 5 ints is a collection of 5 ints in contiguous memory.

    A pointer-to-int is an value which represents the location of an int in
    memory.

    The confusion arises because array accesses are defined in terms of
    pointers. This means that in an expression like 'arr[2]', the identifier
    'arr' which refers to an array "decays" to a pointer-to-first-member;
    then the subscript operator [] is syntactic sugar for '*(arr + 2)', a
    pointer arithmetic and dereference operation.

    Naturally, in an expression like 'ptr[2]', the rules are the same,
    except that 'ptr' is already a pointer value and doesn't need to
    "decay". If 'ptr' points to an element at least 3 before the end of an
    array, then this is a valid expression.

    The FAQ has a very good description of the difference between arrays and
    poitners in question 6.2.

    Philip
     
    Philip Potter, Mar 31, 2008
    #11
  12. Ed Prochak Guest

    On Mar 31, 11:22 am, (Kenny McCormack)
    wrote:
    > In article <>,
    >
    > Willem <> wrote:
    > >Richard wrote:
    > >) But a naive solution would be simply auto reply to each new post
    > >)
    > >) "have you read the FAQ : here ..."

    >
    > >He pointed to a *specific item* in the FAQ.

    >
    > Yes. We all understand that.
    >
    > >) In your haste you seem to have misunderstood. My point is that 99.99% of
    > >) questions here are answered in one way or other by the FAQ,
    > >)
    > >) Simply questioning people as to whether they read it and then somewhat
    > >) pompously pointing them there makes the group pretty much redundant.

    >
    > >He pointed to the *specific part* of the FAQ that answered the question.

    >
    > Yes. We all understand that.


    It was not clear from your posts that you understood that.
    >
    > And, yes, all also understand that that is the part that would be a
    > little tricky about implementing the auto-responder. Save that for
    > Version 2.0.
    >
    > In the meantime, an auto-responder that simply greets every new thread
    > (by a newbie - the program would keep a list of people to exclude from
    > treatment) with "The answer is in the FAQ. Please see the FAQ at: <URL>"
    > would be very nice and save certain people (e.g., Bwian) from having to
    > do it manually.



    But not every new thread by new comers has an answer in the FAQ.

    BTW I noticed that you only responded to RH complaining about his
    post. You never bothered to answer the OP. Maybe next time you will
    lead by example rather than complain?
     
    Ed Prochak, Mar 31, 2008
    #12
  13. Willem Guest

    Ed wrote:
    ) On Mar 31, 11:22 am, (Kenny McCormack)
    ) wrote:
    )> Yes. We all understand that.
    )
    ) It was not clear from your posts that you understood that.

    You're confusing Kenny-the-Troll, who is nothing but a troll,
    with Just-Richard, who's an okay chap although he often has
    opinions I don't share.


    SaSW, Willem
    --
    Disclaimer: I am in no way responsible for any of the statements
    made in the above text. For all I know I might be
    drugged or something..
    No I'm not paranoid. You all think I'm paranoid, don't you !
    #EOT
     
    Willem, Mar 31, 2008
    #13
  14. Richard Guest

    Willem <> writes:

    > Ed wrote:
    > ) On Mar 31, 11:22 am, (Kenny McCormack)
    > ) wrote:
    > )> Yes. We all understand that.
    > )
    > ) It was not clear from your posts that you understood that.
    >
    > You're confusing Kenny-the-Troll, who is nothing but a troll,
    > with Just-Richard, who's an okay chap although he often has
    > opinions I don't share.
    >
    >
    > SaSW, Willem


    Actually I think Kenny is an ok chap too. He and his type (and I am
    similar) are required to stop certain elements getting too carried away
    with their own self importance.
     
    Richard, Mar 31, 2008
    #14
  15. Serve L Guest

    "Richard" <> schreef in bericht
    news:fsrdlf$ikl$...
    > Willem <> writes:
    >
    >> Ed wrote:
    >> ) On Mar 31, 11:22 am, (Kenny McCormack)
    >> ) wrote:
    >> )> Yes. We all understand that.
    >> )
    >> ) It was not clear from your posts that you understood that.
    >>
    >> You're confusing Kenny-the-Troll, who is nothing but a troll,
    >> with Just-Richard, who's an okay chap although he often has
    >> opinions I don't share.
    >>
    >>
    >> SaSW, Willem

    >
    > Actually I think Kenny is an ok chap too. He and his type (and I am
    > similar) are required to stop certain elements getting too carried away
    > with their own self importance.


    What do you think about people who spell the first 2 letters of their name
    with a capital? :p
     
    Serve L, Mar 31, 2008
    #15
  16. Morris Dovey Guest

    Richard wrote:

    > Actually I think Kenny is an ok chap too. He and his type (and I am
    > similar) are required to stop certain elements getting too carried away
    > with their own self importance.


    Umm. How would you rate the self-importance of a person who
    claims sufficient moral superiority stand in judgement of any
    group of strangers?

    --
    Morris Dovey
    DeSoto Solar
    DeSoto, Iowa USA
    http://www.iedu.com/DeSoto/
     
    Morris Dovey, Mar 31, 2008
    #16
  17. Richard Guest

    Morris Dovey <> writes:

    > Richard wrote:
    >
    >> Actually I think Kenny is an ok chap too. He and his type (and I am
    >> similar) are required to stop certain elements getting too carried away
    >> with their own self importance.

    >
    > Umm. How would you rate the self-importance of a person who
    > claims sufficient moral superiority stand in judgement of any
    > group of strangers?


    I have no idea which self righteous crusade you are now, but like many
    others I can only call it as I see it. And there is a rather gaping
    divide between been an arrogant arse and putting people down all the
    time and saying "Hey you, who the hell do you think you are? Calm down
    and give someone else a chance here". If you can't see the fundamental
    difference between the two approaches then there isn't much point
    trying to explain it to you I am afraid. A bit like trying to get
    through to certain elements here that just because they had once or
    twice found a bug from a printout on 500,000 lines of code that that
    does not invalidate good practice in using a debugger responsibly and
    skillfully in order to save time and money.
     
    Richard, Mar 31, 2008
    #17
  18. Morris Dovey Guest

    Richard wrote:
    >
    > Morris Dovey <> writes:
    >
    > > Richard wrote:
    > >
    > >> Actually I think Kenny is an ok chap too. He and his type (and I am
    > >> similar) are required to stop certain elements getting too carried away
    > >> with their own self importance.

    > >
    > > Umm. How would you rate the self-importance of a person who
    > > claims sufficient moral superiority stand in judgement of any
    > > group of strangers?

    >
    > I have no idea which self righteous crusade you are now, but like many
    > others I can only call it as I see it. And there is a rather gaping
    > divide between been an arrogant arse and putting people down all the
    > time and saying "Hey you, who the hell do you think you are? Calm down
    > and give someone else a chance here". If you can't see the fundamental
    > difference between the two approaches then there isn't much point
    > trying to explain it to you I am afraid. A bit like trying to get
    > through to certain elements here that just because they had once or
    > twice found a bug from a printout on 500,000 lines of code that that
    > does not invalidate good practice in using a debugger responsibly and
    > skillfully in order to save time and money.


    Just looking for a little clarification - and guess I got it. :)

    --
    Morris Dovey
    DeSoto Solar
    DeSoto, Iowa USA
    http://www.iedu.com/DeSoto/
     
    Morris Dovey, Mar 31, 2008
    #18
  19. Morris Dovey said:

    > Richard wrote:
    >
    >> Actually I think Kenny is an ok chap too. He and his type (and I am
    >> similar) are required to stop certain elements getting too carried away
    >> with their own self importance.

    >
    > Umm. How would you rate the self-importance of a person who
    > claims sufficient moral superiority stand in judgement of any
    > group of strangers?


    Who cares? It isn't *self*-importance that matters in comp.lang.c. The
    trolls think they're important (i.e. they are self-important), as
    Just-Richard demonstrates above with words like "required", but nobody
    else does.

    If the trolls ever get around to learning how to explain C to other people
    instead of filling the group with their bile, maybe they will become
    *genuinely* important. If it ever occurs and you happen to notice, do let
    me know.

    --
    Richard Heathfield <http://www.cpax.org.uk>
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999
     
    Richard Heathfield, Mar 31, 2008
    #19
  20. Morris Dovey Guest

    Richard Heathfield wrote:

    > If the trolls ever get around to learning how to explain C to other people
    > instead of filling the group with their bile, maybe they will become
    > *genuinely* important. If it ever occurs and you happen to notice, do let
    > me know.


    I've been watching. I figure that if they hang around long
    enough, they won't be able to help learning enough to help
    /somebody/ with /something/.

    :)

    --
    Morris Dovey
    DeSoto Solar
    DeSoto, Iowa USA
    http://www.iedu.com/DeSoto/
     
    Morris Dovey, Mar 31, 2008
    #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. Armel HERVE

    Why a crash ?

    Armel HERVE, Sep 29, 2003, in forum: Java
    Replies:
    10
    Views:
    714
    Armel HERVE
    Sep 30, 2003
  2. Alf P. Steinbach

    Re: Why does this crash?

    Alf P. Steinbach, Jul 18, 2003, in forum: C++
    Replies:
    5
    Views:
    381
  3. Developwebsites

    why does it crash?

    Developwebsites, Oct 10, 2003, in forum: C++
    Replies:
    6
    Views:
    370
    Jerry Coffin
    Oct 11, 2003
  4. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    991
    Mark Rae
    Dec 21, 2006
  5. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,261
    Smokey Grindel
    Dec 2, 2006
Loading...

Share This Page