Wiki Page Content

Differences between revisions 2 and 3
Revision 2 as of 2010-08-22 20:31:17
Size: 2241
Editor: SheenaSmith
Comment: update content (from Sam)
Revision 3 as of 2010-10-13 18:56:23
Size: 2357
Editor: SheenaSmith
Comment: update content - pointers, structs
Deletions are marked like this. Additions are marked like this.
Line 19: Line 19:
||'''context'''||a pointer to an SDL_RWops structure|| ||'''context'''||,,a pointer to ,,an SDL_RWops structure ^containing the read function^???||
Line 23: Line 23:

<<Color2(green,I think '''ptr''' is an exception to the 'pointer rule'.)>>

DRAFT

SDL_RWread

Use this function to read from a data source -or- *call the function pointed to by an SDL_RWops structure's read member.*

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 containing the read function???

ptr

*a pointer to an area of memory to read data into*

size

*the size of each block of memory to read*

maxnum

*the maximum number of memory blocks to read (it may read less)*

green

Return Value

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

-or-

*Returns the number of memory blocks read, or -1 if the read failed*; call SDL_GetError() for more information.

Code Examples

*

#include <stdio.h>
#include "SDL_rwops.h"
int main()
{
  int blocks;
  char buf[256];
  SDL_RWops *rw=SDL_RWFromFile("file.bin","rb");
  if(rw==NULL)
  {
    fprintf(stderr,"Couldn't open file.bin\n");
    return(1);
  }

  blocks=SDL_RWread(rw,buf,16,256/16);
  SDL_RWclose(rw);
  if(blocks<0)
  {
    fprintf(stderr,"Couldn't read from file.bin\n");
    return(2);
  }

  fprintf(stderr,"Read %d 16-byte blocks\n",blocks);
  return(0);
}

*

Remarks

*
This is not a built in function. This is a C macro that calls whatever function happens to be in the 'read' member of the SDL_RWops structure.
*

SDL_RWread reads up to maxnum objects each of size size from the data source to the area pointed at by ptr. green

green


CategoryAPI, CategoryIO

None: SDL_RWread (last edited 2015-09-17 21:55:16 by PhilippWiesemann)

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