By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,819 Members | 1,173 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,819 IT Pros & Developers. It's quick & easy.

odd C++ crash question with streams

P: n/a
Hi. What does it mean if my application is crashing on a cout<< line?
specifically:

cout<<"hello"<<endl

does not crash it, but

int i=0;
cout<<"hello"<<i<<endl;

does.

the crash is:

"unhandled exception at 0x00450460 in main.exe: 0xC0000005: Access
violation reading location 0x00000000"

Thanks!

Jul 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
laniik wrote:
Hi. What does it mean if my application is crashing on a cout<< line?
specifically:

cout<<"hello"<<endl

does not crash it, but

int i=0;
cout<<"hello"<<i<<endl;

does.

the crash is:

"unhandled exception at 0x00450460 in main.exe: 0xC0000005: Access
violation reading location 0x00000000"

Thanks!

If you show us a minimal compilable program that exhibits this behavior,
someone here might be able to help you. Absent that, there's absolutely
no way to tell.

Cheers,
--ag

--
Artie Gold -- Austin, Texas
http://it-matters.blogspot.com (new post 12/5)
http://www.cafepress.com/goldsays
Jul 23 '05 #2

P: n/a
hmm, this is part of a larger program where its obviously somthing in
the code executed before this that is causing the problem. however i
cannot post the whole code, so i was hoping that someone might
recognize this error as being caused by something in specific that i
could look for in the code. but i agree, unless you've seen it before,
its not much to go on.

Jul 23 '05 #3

P: n/a
Are you dealing with pointers at all? Perhaps you have instead of i
being an int it's an int*, and you're doing << *i? If so, look to be
sure that i is properly initialized or set to whatever. It's trying to
read something at address 0, which is a Bad Thing(TM).

Other than that... I don't really have any idea.

Jul 23 '05 #4

P: n/a
i looked around and found that stuff like this with streams can happen
when the memory gets corrupted by accidental overwriting. this causes
the streams to be unable to allocate memory for the int in that line.

turns out i was writing a block of memory 2 bytes too large for the
allocated space. of course, this couldnt give me some kind of error at
that line, it has to manifest itself in some bizarre standard library
call.

hehe. i love c++

thanks for the help!

Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.