473,399 Members | 3,603 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,399 software developers and data experts.

odd C++ crash question with streams

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
4 1514
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Raj Batra | last post by:
Hi, I've created a dll that you can import into python. The function calls an ostringstream class. Calling this function repeatedly in python will cause a Microsoft Visual C++ Debug Library...
3
by: Tron Thomas | last post by:
What does binary mode for an ofstream object do anyway? Despite which mode the stream uses, operator << writes numeric value as their ASCII representation. I read on the Internet that it is...
8
by: bonj | last post by:
hello I hope somebody can help me get my head around this area of 'stream' programming... I know that streams are very fashionable nowadays so hopefully there'll be lots of replies. ;-) ...
6
by: KevinD | last post by:
assumption: I am new to C and old to COBOL I have been reading a lot (self teaching) but something is not sinking in with respect to reading a simple file - one record at a time. Using C, I am...
2
by: bonk | last post by:
Hello how do I connect streams in c# ? Imagine the followung scenario: I have a StreamWriter that writes Text to a Stream. How can I tell that Stream to pass that Data to another Stream...
4
by: Detlef Huettenbach | last post by:
I was trying to convert a Windows Forms prototype application to an ASP.NET solution that makes use of loading data streams into the Image Web/Windows control. For WinForms no problem. However in...
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...
110
by: alf | last post by:
Hi, is it possible that due to OS crash or mysql itself crash or some e.g. SCSI failure to lose all the data stored in the table (let's say million of 1KB rows). In other words what is the worst...
4
by: floppyzedolfin | last post by:
Hello! I'm actually encoding an encryption / decryption program. The encryption programes takes a file path in parameter, and encrypts the contents of the file and stores that into another file. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.