473,385 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

why do the following crash

File1.c

int arr[80];

File2.c

extern int *arr;
int main()
{
arr[1] = 100;
return 0;
}
Mar 31 '08 #1
24 1324
pa********@hotmail.com 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
Mar 31 '08 #2

Philip Potter <pg*@doc.ic.ac.ukwrites:
pa********@hotmail.com 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.
Mar 31 '08 #3
On Mar 31, 8:56 am, Richard <de...@gmail.comwrote:
Philip Potter <p...@doc.ic.ac.ukwrites:
parag_p...@hotmail.com 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
Mar 31 '08 #4
Ed Prochak <ed*******@gmail.comwrites:
On Mar 31, 8:56 am, Richard <de...@gmail.comwrote:
>Philip Potter <p...@doc.ic.ac.ukwrites:
parag_p...@hotmail.com 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.

Mar 31 '08 #5
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/
Mar 31 '08 #6
parag_paul wrote:
File1.c

int arr[80];

File2.c

extern int *arr;
int main()
{
arr[1] = 100;
return 0;
}
cf. http://c-faq.com/aryptr/aryptr1.html
Mar 31 '08 #7
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
Mar 31 '08 #8
In article <sl********************@snail.stack.nl>,
Willem <wi****@stack.nlwrote:
>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.

Mar 31 '08 #9

<pa********@hotmail.comwrote in message
news:f5**********************************@q27g2000 prf.googlegroups.com...
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

Mar 31 '08 #10
Bartc wrote:
<pa********@hotmail.comwrote in message
news:f5**********************************@q27g2000 prf.googlegroups.com...
>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
Mar 31 '08 #11
On Mar 31, 11:22 am, gaze...@xmission.xmission.com (Kenny McCormack)
wrote:
In article <slrnfv1vfa.159s.wil...@snail.stack.nl>,

Willem <wil...@stack.nlwrote:
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?
Mar 31 '08 #12
Ed wrote:
) On Mar 31, 11:22 am, gaze...@xmission.xmission.com (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
Mar 31 '08 #13
Willem <wi****@stack.nlwrites:
Ed wrote:
) On Mar 31, 11:22 am, gaze...@xmission.xmission.com (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.
Mar 31 '08 #14

"Richard" <de***@gmail.comschreef in bericht
news:fs**********@registered.motzarella.org...
Willem <wi****@stack.nlwrites:
>Ed wrote:
) On Mar 31, 11:22 am, gaze...@xmission.xmission.com (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

Mar 31 '08 #15
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/
Mar 31 '08 #16
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
Mar 31 '08 #17
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/
Mar 31 '08 #18
Willem wrote:
Ed wrote:
) On Mar 31, 11:22 am, gaze...@xmission.xmission.com (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.
You mean Riley. Uh, no. Also a troll.


Brian
Mar 31 '08 #19
On 31 Mar 2008 at 20:59, Default User wrote:
Willem wrote:
>Ed wrote:
) On Mar 31, 11:22 am, gaze...@xmission.xmission.com (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.

You mean Riley. Uh, no. Also a troll.
The modern definition of a troll is someone whose views you disagree
with, so you're saying the same thing. It's just that Default Loser is a
showing himself yet again to be a pathetic little worm.

Mar 31 '08 #20
Willem wrote:
Ed wrote:
) On Mar 31, 11:22 am, gaze...@xmission.xmission.com (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.
I incline to disagree - just-richard has also shown himself to be a
troll, as in this thread, where instead of either answering the OP or
noticing that Philip Potter's comment was entirely correct, he flamed
him for no reason at all.
Mar 31 '08 #21
On Apr 1, 8:03 am, Willem <wil...@stack.nlwrote:
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.
This 'Richard' is surely a troll. Philip Potter
answered a frequently-asked question by linking
to an exact entry in the FAQ, and 'Richard' flamed
him for it.
Apr 1 '08 #22
Ed Prochak wrote:
gaze...@xmission.xmission.com (Kenny McCormack) wrote:
.... snip ...
>
>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?
McCormack is a pure troll. Best plonked. Never feed.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.

--
Posted via a free Usenet account from http://www.teranews.com

Apr 1 '08 #23
"Morris Dovey" <mr*****@iedu.comwrote in message
news:47***************@iedu.com...
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/.

:-)
I think that they are genuinely incapable. Otherwise, we would have seen it
by now.

--
Posted via a free Usenet account from http://www.teranews.com

Apr 1 '08 #24
Ed Prochak wrote:
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?
It seems Mr Heathfield's notoriety has grown to the point that he is
credited with actions he had nothing to do with...

In any case, I stand by my original post. I agree that for a newbie (or
even an oldbie) it can be difficult to find the correct question in the
FAQ [1] - especially since some questions are rather cross-category, so
there's no shame in not finding the answer in the FAQ. Similarly, when
the FAQ has already answered the question, there seems little point in
repeating the information myself - especially since I could easily make
a mistake when answering. The FAQ is tried-and-tested, and the number of
mistakes it makes are probably much less than the number I make. If the
OP doesn't understand the FAQ answer, or has further questions, he is
free to ask in a followup.

I meant my question "Did you read the FAQ?" as a genuine
request-for-information, not a rhetorical device, though I can see that
it may have seemed a bit short with him. I'll try to improve the style
of my posting, but I see no reason to change the content.

Philip

[1] Incedentally, this is precisely the reason that an autoresponder
would be a bad idea.
Apr 1 '08 #25

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

48
by: Joseph | last post by:
Hi I'm writing a commercial program which must be reliable. It has to do some basic reading and writing to and from files on the hard disk, and also to a floppy. I have foreseen a potential...
8
by: Eric Brunel | last post by:
Hi all, I was creating a Tkinter widget in the style of the reversed tabs below Excel worksheets and I stepped in a serious problem: the code I made makes python crash with a seg fault, bus...
2
by: Dom | last post by:
Hi, I am trying to get a dynamic table going. You click a button to add a row. In the newly created row a button to delete the row is placed (try the code example below). In Netscape, pressing...
0
by: roni | last post by:
hi. i have application written in vb.net + managed c++ dll that call also to unmanaged c++ function. the application crash. i open the dump file of the crash with WinDbg and that's is the...
10
by: xixi | last post by:
i have db2 udb v8.1 on windows 64 bit 2003 server, after db2 server start , i found this in the db2diag.log, is this error? 2004-05-05-15.28.30.780000 Instance:DB2 Node:000...
4
by: arizvi | last post by:
Hi, My program crashes when it reaches a certain line. There is nothing wrong with that particular line as I have changed it to something simple like i=0, and it still crashes. If I remove...
34
by: NewToCPP | last post by:
Hi, Why does a C/C++ programs crash? When there is access to a null pointer or some thing like that programs crash, but why do they crash? Thanks.
12
by: benjamin.krulewitch | last post by:
I'm debugging an issue with a C program that causes the computer to crash, and I'm attempting to log information immediately before the crash occurs. I us my BKprintLog function (see below) to...
4
by: eskimo | last post by:
Hello I have a situation, my program has a crash (SIGSEGV) for a reason that I don't know yet. I tried to analyze it using Valgrind but when I invoke the program with Valgrind, the crash no longer...
11
by: =?Utf-8?B?R2VyaGFyZA==?= | last post by:
I have run into a situation that if a page/tab that uses the Ajax toolkit (using .net version 3.5) is closed before the Ajax enable controls complete loading, then IE locks up. Does it in both IE7...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.