Skip to main content
deleted 193 characters in body
Source Link

Is this stackExchange forum open yet ?

You should rather seek for help on the official reddit community (http://www.reddit.com/r/cs50)

However I will still try to answer you question : WhenWhen you open a file a cursor is set somewhere in it (look at man fopen for more about that) and you can change this cursor position using fseek. When you read a "block" (in your case you read sizeof(RGBTRIPLE) bytes) from your file using fread the cursor will be move forward automatically by sizeof(RGBTRIPLE) bytes since your cursor needs to be on each character to read it and to put it in a buffer. You can't read some bytes without moving your cursor (at least not to my knowledge). If you want to go back where you were in your file before reading a triple you use this : fseek(fp, - sizeof(RGBTRIPLE), SEEK_CUR); .

I hope I was clear enough.

Maxow / Eric

Is this stackExchange forum open yet ?

You should rather seek for help on the official reddit community (http://www.reddit.com/r/cs50)

However I will still try to answer you question : When you open a file a cursor is set somewhere in it (look at man fopen for more about that) and you can change this cursor position using fseek. When you read a "block" (in your case you read sizeof(RGBTRIPLE) bytes) from your file using fread the cursor will be move forward automatically by sizeof(RGBTRIPLE) bytes since your cursor needs to be on each character to read it and to put it in a buffer. You can't read some bytes without moving your cursor (at least not to my knowledge). If you want to go back where you were in your file before reading a triple you use this : fseek(fp, - sizeof(RGBTRIPLE), SEEK_CUR); .

I hope I was clear enough.

Maxow / Eric

When you open a file a cursor is set somewhere in it (look at man fopen for more about that) and you can change this cursor position using fseek. When you read a "block" (in your case you read sizeof(RGBTRIPLE) bytes) from your file using fread the cursor will be move forward automatically by sizeof(RGBTRIPLE) bytes since your cursor needs to be on each character to read it and to put it in a buffer. You can't read some bytes without moving your cursor (at least not to my knowledge). If you want to go back where you were in your file before reading a triple you use this : fseek(fp, - sizeof(RGBTRIPLE), SEEK_CUR); .

I hope I was clear enough.

Maxow / Eric

Post Undeleted by Robert Cartaino
Mod Converts to Comment
Post Deleted by Robert Cartaino
Source Link
ItsEric
  • 198
  • 1
  • 6

Is this stackExchange forum open yet ?

You should rather seek for help on the official reddit community (http://www.reddit.com/r/cs50)

However I will still try to answer you question : When you open a file a cursor is set somewhere in it (look at man fopen for more about that) and you can change this cursor position using fseek. When you read a "block" (in your case you read sizeof(RGBTRIPLE) bytes) from your file using fread the cursor will be move forward automatically by sizeof(RGBTRIPLE) bytes since your cursor needs to be on each character to read it and to put it in a buffer. You can't read some bytes without moving your cursor (at least not to my knowledge). If you want to go back where you were in your file before reading a triple you use this : fseek(fp, - sizeof(RGBTRIPLE), SEEK_CUR); .

I hope I was clear enough.

Maxow / Eric