On 05/07/2013 07:02 PM, Brian Dude wrote:
> Hello, I'm working on some graphics routines and just started trying to
> read in some bitmap files. For troubleshooting, I'm printing out various
> values to make sure they're all okay.
>
> I have two globals and a local whose values I wanted to verify. I made a
> bitmap header structure for obtaining info.
>
> int chunx;
> int scan;
>
> int main(int argc,char *argv[])
> {
> int slwb; /*Scan Line Width in Bytes*/
> struct W3_BMP_header Q;
> long int X;
> FILE *bmpsource;
bmpsource is uninitialized here.
> /*other variables*/
>
> readBMheader(&Q,bmpsource);
You use bmpsource here, despite the fact that it hasn't been
initialized. I hope that in your actual code, bmpsource is filled in by
a call to fopen()? Another indication that this program is incomplete is
your use of struct W3_BMP_header, FILE, readBMPheader(), and printf().
Each of those is probably declared in a header file, and your code, as
written, doesn't #include any headers.
Please keep in mind that if you knew what was wrong with your program,
you wouldn't be coming here for help. Since you don't know what's wrong
with it, there's a very good chance that something you think is
irrelevant, isn't. Therefore, don't cut out anything just because you
think it's irrelevant. Show us a program as simple as possible, while
still demonstrating the problem. However, show us the complete program,
not just the part you think is relevant. Do not re-type the program -
cut and paste it directly from the source - otherwise we may end up
wasting time investigating the typos you introduced while re-typing the
code.
> scan=(int)Q.height;
Q.height was uninitialized at the start of your program. The only code
you've shown us that had any chance of setting it to a defined value
before this line is executed was the call to readBMPheader(). Therefore,
if some thing's wrong, it's probably because readBMPheader() is not
doing what you think it should be doing. This, in turn, is probably
because you were wrong about what you thought it should be doing (the
problem could be in readBMPheader(), but in general it's more likely to
be your code). That means that this isn't a C problem, it's a problem
with whatever package readBMPheader() is part of. Therefore, you'll
probably get better help with your problem by taking it to a forum
devoted to that package. comp.lang.c isn't that forum.
--
James Kuyper