File Stream change its address during writing text contents to the stream

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

File Stream change its address during writing text contents to the stream

Hi guys,

I wrote a program to write text contents to file stream through fputs, the file stream address was changed
in the middle of writing text content to the stream (11% text content have been put into the file stream),
that cause the file stream pointer can be evaluated problem and raise exception on stream validation code in fputs library function, my question is what things could go wrong to make file stream pointer changed its address to something else or a NULL pointer if the file stream have not been flushed and closed.

Re: File Stream change its address during writing text contents to the stream

Thanks Paul.

The file stream pointer is global and initialized variable, I did some debug on this file stream, the address was changed to 0x00000000 or 0xsomeFFFF sometime or oxFFFFFFFF other time, and indeed only the file stream address change cause exception, but don't know what cause its address change, dose the file stream goes to buffer overrun or other buffer overrun, uninitialized variable, invalid pointer access to cause the file stream change its address end up to the file stream can not evaluated?

Re: File Stream change its address during writing text contents to the stream

Originally Posted by jjsun

Thanks Paul.

The file stream pointer is global and initialized variable, I did some debug on this file stream, the address was changed to 0x00000000 or 0xsomeFFFF sometime or oxFFFFFFFF other time, and indeed only the file stream address change cause exception, but don't know what cause its address change,

The reason for this is, again, bad coding on your part. Unless we see the code, that is all anyone can tell you. Unlike other programming languages, when you make a mistake in your code such as the ones I pointed out, anything can and will happen.

Second, if you actually see your variable change while stepping into your program, then why is it you can't determine what may have changed the value? What line of code caused the address to change? Whatever that line of code is, that is what you should be investigating.

Unless we actually see the code, just describing what you're doing is not enough information. A description is really what you would like the code to do, and then assumed that is what you coded the program to do -- it does not mean that the actual code is doing what you say it's doing. Let others see the code.