Well what format is this image file in?
BMP format perhaps?
Though most newbies start with mazes defined in ascii art, like this
#S########
# #
###### #
# #
#E########
Find a route through the maze from S to E
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
Perhaps start with an ASCII-art map like I posted above, and then develop the maze solving code.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
FILE *fp = fopen( "file.bmp", "rb" );
This opens the file unsigned char buff[10];
size_t n = fread( buff, sizeof(buff[0]), sizeof(buff), fp );
This reads 10 bytes from the file.
10 is obviously just an example, but you can read the documentation to find out how big a BMPHEADER structure is, and read that number of bytes instead. Having got that, you get vital information such as
- the width and height of the image
- the number of bits in each pixel
- whether there is a colour table in the file.
You then skip the optional colour table (say by using fseek), then you can start looping reading image data, based on your knowledge of the width, height and bpp of the image format.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
> Do U mean that this command only allow me to read only 10bytes of data from the file only?
That was an example - read the documentation to decide how many to read.
Short of actually posting the actual code en-masse (which isn't going to happen), I don't know what else to tell you. You can read from 1 byte to the whole file, the choice is yours.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953