I've been stuck on Pset4 resize.c for a week now. I test my code with small.bmp which cs50 have provided, my first initial problem was that i only got half the image size to resize but after further research and thinking, i finally managed to get the full image size. My only problem now is the colors are random, i have no clue where it's going wrong now, i'm frustrated with this and i just need some help, can anyone please help me out here with this? My code: https://gist.github.com/6717633f6f48c11c6974359db8197f5c

Update: Code resizes with green and white when using small.bmp, except the white isn't inside the middle,it's to the top. I feel like i'm close but i felt that way for the previous code and it turned out to have more than one issue so, what now with this one? Thanks in advance for your response. Updated code: https://gist.github.com/9713c1e508a861847419e4803da41b40


There are a couple of issues. First, because of the structure of the nested for loops and what is placed where, the code is adding padding after each pixel. Padding should only be added at the end of each row.

Next, there are problems with the numerous calls to fseek. The fseek calls should only be used in the input file to skip over padding, and more importantly, to move backwards to the beginning of each line to make the correct number of copies of each line, which implies an if statement.

I'll leave it to you to rethink the problems and try again. If, after a good effort, you still can't resolve, update the question with new code and leave a comment.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

  • Thank you so much for pointing me into the right direction, i still haven't got it yet but i did however try too, above i've updated the code as you asked and i await your assistance. Thank you so much again. :) Nov 16 '16 at 3:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .