Wiki Page Content

Revision 5 as of 2013-08-08 18:35:27

Clear message

SDL_RWread

Use this function to read from a data source.

Syntax

size_t SDL_RWread(struct SDL_RWops* context,
                  void*             ptr,
                  size_t            size,
                  size_t            maxnum)

Function Parameters

context

a pointer to an SDL_RWops structure

ptr

a pointer to a buffer to read data into

size

the size of each object to read, in bytes

maxnum

the maximum number of objects to be read

Return Value

Returns the number of objects read, or 0 at error or end of file; call SDL_GetError() for more information.

Code Examples

SDL_RWops *rw = SDL_RWFromFile("test.bin","r");
if (rw != NULL) {
  extern Uint8 buf[256];
  SDL_RWread(rw, buf, sizeof (buf));
  SDL_RWclose(rw);
}

Remarks

This function reads up to maxnum objects each of size size from the data source to the area pointed at by ptr. This function may read less objects than requested. It will return zero when there has been an error or the data stream is completely read.

SDL_RWread is actually a macro that calls the SDL_RWops's read method appropriately, to simplify application development.


CategoryAPI, CategoryIO

(Page Info.)
Feedback
Please include your contact information if you'd like to receive a reply.
Submit