SDL_GetClipboardText(3)
π NAME π
SDL_GetClipboardText β bestie, it grabs the UTF-8 text from the clipboard. That's it, that's the whole job β¨
This one lives in the SDL3 functions crew, and yes she's a main character.
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_clipboard.h>
char * SDL_GetClipboardText(void);
No arguments. No drama. Just vibes and a char * π«Ά
β¨ DESCRIPTION β¨
Okay so here's the tea: this function returns an empty string if there isn't enough memory left for a copy of the clipboard's content. Like, she tried her best, but the malloc said no π
That's the only caveat listed, and it's lowkey important, so don't come for me when you get "" back and assume the clipboard was empty. It might just be broke. iykyk
π RETURN VALUE π
- On success β you get the clipboard text back. Slay π
- On failure β you get an empty string instead. Call
SDL_GetError()for more information, she'll tell you what went wrong π₯Ί
Important, bestie: whatever you get back must be freed with SDL_free() when it is no longer needed. Don't just walk away from it, that's a memory leak and leaks are not the aesthetic π
π§ THREAD SAFETY π§
This function should only be called on the main thread. Periodt. Don't try to be cute and call her from a worker thread, she will not answer π
π¦ AVAILABILITY π¦
She's been serving since SDL 3.2.0. Anything older? Sorry babe, not available π
β SEE ALSO β
SDL_HasClipboardText(3)β the vibe check: is there even text in there? πSDL_SetClipboardText(3)β the other half of the duo, she's the one who puts stuff in π
And that's the whole page, no cap. This lil love letter comes to you from Simple Directmedia Layer, SDL 3.4.18 edition π Go forth, read your clipboard, free your strings, and stay on the main thread bestie π«Άβ¨
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms