Wiki Page Content

Differences between revisions 1 and 2
Revision 1 as of 2010-07-15 20:30:55
Size: 2113
Editor: SheenaSmith
Comment: create page, add content (Wed Mar 10 ver; changeset 4428)
Revision 2 as of 2010-08-22 21:17:48
Size: 2345
Editor: SheenaSmith
Comment: update content (from Sam)
Deletions are marked like this. Additions are marked like this.
Line 6: Line 6:
Use this function (macro) to *call the write function in an SDL_RWops structure.* Use this function to write to a data source ''-or-'' *call the write function in an SDL_RWops structure.*
Line 12: Line 12:
SDL_RWwrite(ctx, ptr, size, n) size_t SDL_RWwrite(struct SDL_RWops* context,
                   const void* ptr,
                   size_t size,
                   size_t num)
Line 14: Line 17:
<<Color2(green,Should there be anything to indicate a RV at the beginning of the syntax? Should the 4 params be on separate lines like a regular function even though the rest of the syntax is different? Should the following be included in the syntax section?)>>
 (ctx)->write(ctx, ptr, size, n)
Line 18: Line 19:
||'''ctx'''||*a pointer to an SDL_RWops structure*|| ||'''context'''||a pointer to an SDL_RWops structure||
Line 21: Line 22:
||'''n'''||*the exact number of memory blocks to write*|| ||'''num'''||*the exact number of memory blocks to write*||
Line 24: Line 25:
Returns the number of objects written, or 0 at error or end of file; call [[SDL_GetError]]() for more information.

''-or-''
Line 60: Line 65:
*,,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.* *<<BR>>This is not a built-in function. This is a macro that calls whatever write function happens to be in the SDL_RWops structure.<<BR>>*

[[SDL_RWwrite]] writes exactly '''num''' objects each of size ,,'''objsize''',, '''size''' from the area pointed at by '''ptr''' to data source. <<Color2(green,Should SDL_RWwrite have () like a function even though it's a macro?)>>
Line 63: Line 70:
 .[[SDL_RWclose]] (Macro) *???
 .[[SDL_RWFromFile]] *???
 .[[SDL_RWread]] (Macro) *???
 .[[SDL_RWseek]](Macro) *???
 .[[SDL_RWclose]] (Macro) *
 .[[SDL_RWFromFile]] *
 .[[SDL_RWread]] (Macro) *
 .[[SDL_RWseek]](Macro) *

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

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*

num

*the exact number of memory blocks to write*

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*; 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 '''objsize''' 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