Next time, please post your code in [code][/code] tags. It should look like this:
Code:
FILE *image =fopen ("file.txt", "rt");
fget(work.bmp, sizeof(work.bmp)+1, imagine);
Some things I can see from the two lines you posted:

  • The function is fgets, not fget. More documentation in the man page if you need it.
  • You call the file pointer image, but in your fgets call, you use the name imagine.
  • You're trying to read into work.bmp, but it's not clear (because you didn't post enough code) whether that's a valid name of a struct and struct member, or you're confused on what exactly you're trying to do.


Always remember, if you can't solve a problem yourself, you will never be able to program a computer to solve it. So first you must understand what the problem is asking, and how, in general, to do that problem. Start by reading up on the bitmap file format.

Once you understand the problem and it's solution in general, you will want to begin writing out the steps your program needs to take, like directions you would find in a repair manual or baking recipe, etc. Something like:

  1. Open file.txt.
  2. Read the first line to determine the name of the bitmap file.
  3. Open that bitmap file (using a second FILE *). Note that bitmap files are binary, not text, so open in binary mode.
  4. Read the header info, using fread (which is used for reading binary info)
  5. ...


Note that some of those are relatively easy: open a file with fopen, read a line with fgets, open another file with fopen. If you have a step that is more complicated or involved, you can break it into sub-steps.

For example, reading the header may be broken down into
4.a. Read the signature
4.b Read the file size field
4.c Skip the next X bytes
4.d ...