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 ⭐


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