Wiki Page Content

Differences between revisions 3 and 4
Revision 3 as of 2010-08-23 00:20:22
Size: 2327
Editor: SheenaSmith
Comment: update content (w/ Sam)
Revision 4 as of 2010-10-13 19:44:48
Size: 2466
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'''||an SDL_RWops structure ^containing the write function^||
Line 23: Line 23:

<<Color2(green,I think '''ptr''' is an exception to the 'pointer rule'.)>>
Line 29: Line 31:
*On success, it returns the number of memory blocks you told it to write. If it couldn't write that exact number of blocks, or the write didn't work at all, it returns -1*; call [[SDL_GetError]]() for more information. *>>On success,>> ,,it ,,returns the number of memory blocks you told it to write >> >>. If it couldn't write that exact number of blocks, or the write didn't work at all, it returns ,,-1,, ^a negative error code^*; call [[SDL_GetError]]() for more information.

DRAFT

SDL_RWwrite

Use this function to write to a data source -or- *call the write function in an SDL_RWops structure.*

Syntax

size_t SDL_RWwrite(struct SDL_RWops* context,
                   const void*       ptr,
                   size_t            size,
                   size_t            num)

Function Parameters

context

an SDL_RWops structure containing the write function

ptr

*a pointer to an area in memory to read data from*

size

*the size of the memory blocks to write*

num

*the exact number of memory blocks to write*

green

Return Value

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

-or-

*>>On success,>> it returns the number of memory blocks you told it to write >> >>. If it couldn't write that exact number of blocks, or the write didn't work at all, it returns -1 a negative error code*; call SDL_GetError() for more information.

Code Examples

*

#include <stdio.h>
#include <string.h>
#include "SDL_rwops.h"

int main()
{
  int written;
  char *str="Hello World";

  SDL_RWops *rw=SDL_RWFromFile("test.bin","wb");
  if(rw==NULL)
  {
    fprintf(stderr,"Couldn't open test.bin\n");
    return(1);
  }

  written=SDL_RWwrite(rw,str,1,strlen(str));
  SDL_RWclose(rw);
  if(written<0)
  {
    fprintf(stderr,"Couldn't write to test.bin\n");
    return(2);
  }

  fprintf(stderr,"Wrote %d 1-byte blocks\n",written);
  return(0);
}

*

Remarks

*
This is not a built-in function. This is a macro that calls whatever write function happens to be in the SDL_RWops structure.
*

SDL_RWwrite writes exactly num objects each of size size from the area pointed at by ptr to data source. green

green


CategoryAPI, CategoryIO

None: SDL_RWwrite (last edited 2015-06-20 20:03:24 by PhilippWiesemann)

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