Hi!!!!!!
THANK YOU EVERYONE for making me realize that there is indeed an
problem with my program and not with the file pointers. I am glad to
inform you that I have found the problem and fixed it.
Initially I was opening the file in Binary Mode but the syntax was as
follows:
stream = fopen( "encoded.enc", "r , b" )
With this syntax the compiler was not stating any syntax error but the
file was always opened in Text Mode. Then I changed the syntax as
follows:
stream = fopen( "encoded.enc", "r""b" )
(Note the change from "r , b" to "r" "b" )
Complier accepted this syntax too and this time the file opened in
Binary Mode and the problem was fixed.
Again, Thank you.
Sincerely,
Ritesh
CBFalconer <cb********@yahoo.com> wrote in message news:<42***************@yahoo.com>...
Ritesh wrote:
I am a final year engineering student. I am making a final year
project on reed-solomon codec in C using VC++ 6.0.
If that matters you are off-topic here. However it is probably
immaterial.
The input to the program can be any file that the user wants to
encode and then later decode.
This is where I have a problem. I am using fopen, fscanf and
fprintf for input output purposes. I know these are the simple and
std means of doing so. Unfortunately when I run the program the
file pointer for the output stream (sometimes) start printing a
few junk characters (any where in the middle of the file) and then
jumps back many places and starts printing from there. When this
error occurs it prints a few lines and then stops printing
completely.
I am NOT USING ANY function in my program that makes the file
pointer jump back.
Yes you are, or it wouldn't be doing it. It smells like a wild
pointer somewhere, or other means of invoking undefined behaviour.
Lacking the source, we can help no further.
You should reduce the program to a minimal compilable unit that
demonstrates the problem. Not over about 100 lines. Publish that
here if you haven't already found your mistake.
Since you are using the broken google interface, pay close
attention to my sig lines, below. Then trim the quotes to the
relevant portion, and do not top-post.
Hi!!!!!!
THANK YOU EVERYONE for making me realize that there is indeed an
problem with my program and not with the file pointers. I am glad to
inform you that I have found the problem and fixed it.
Initially I opening the file in Binary Mode but the syntax was as
follows:
stream = fopen( "encoded.enc", "r , b" )
With this syntax the compiler was not stating any syntax error but the
file was always opened in Text Mode. Then I changed the syntax as
follows:
stream = fopen( "encoded.enc", "r""b" )
(Note the change from "r , b" to "r" "b" )
Complier accepted this syntax too and this time the file opened in
Binary Mode and the problem was fixed.
Again, Thank you.
Sincerely,
Ritesh