Wiki Page Content

Revision 1 as of 2010-07-15 20:30:55

Clear message

DRAFT

SDL_RWwrite

Use this function (macro) to *call the write function in an SDL_RWops structure.*

Syntax

SDL_RWwrite(ctx, ptr, size, n)

green

  • (ctx)->write(ctx, ptr, size, n)

Function Parameters

ctx

*a pointer to an SDL_RWops structure*

ptr

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

size

*the size of the memory blocks to write*

n

*the exact number of memory blocks to write*

Return Value

*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.

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

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

green


CategoryAPI, CategoryIO

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