|
Size: 1782
Comment: Sorted related functions, see SGFunctions.
|
← Revision 10 as of 2015-06-20 20:03:24 ⇥
Size: 1805
Comment: Added name and links to SDL_RWops.
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 5: | Line 5: |
| Use this function to write to a data stream. | Use this function to write to an [[SDL_RWops]] data stream. |
| Line 18: | Line 18: |
| ||'''context'''||a pointer to an SDL_RWops structure|| | ||'''context'''||a pointer to an [[SDL_RWops]] structure|| |
| Line 44: | Line 44: |
| SDL_RWwrite is actually a macro that calls the SDL_RWops's '''write''' method appropriately, to simplify application development. | SDL_RWwrite is actually a macro that calls the [[SDL_RWops]]'s '''write''' method appropriately, to simplify application development. |
SDL_RWwrite
Use this function to write to an SDL_RWops data stream.
Contents
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 a buffer containing data to write |
size |
the size of an object to write, in bytes |
num |
the number of objects to write |
Return Value
Returns the number of objects written, which will be less than num on error; call SDL_GetError() for more information.
Code Examples
SDL_RWops *rw = SDL_RWFromFile("hello.txt", "w");
if(rw != NULL) {
const char *str = "Hello World";
size_t len = SDL_strlen(str);
if (SDL_RWwrite(rw, str, 1, len) != len) {
printf("Couldn't fully write string\n");
} else {
printf("Wrote %d 1-byte blocks\n", len);
}
SDL_RWclose(rw);
}
Remarks
This function writes exactly num objects each of size size from the area pointed at by ptr to the stream. If this fails for any reason, it'll return less than num to demonstrate how far the write progressed. On success, it returns num.
SDL_RWwrite is actually a macro that calls the SDL_RWops's write method appropriately, to simplify application development.
