How do you copy/paste from the clipboard in C++?

Viewed 50863

I'm still a C++ newbie who has only recently learned some file manipulation. I looked it up online and the codes given are way beyond my current skill. Is there a simple way to do this, or are there any good tutorials that can explain this from the very basics?

5 Answers

You can use ClipboardXX library for copy and pasting simple texts. Just download clipboardXX.hpp from github and copy it to your project path. Then follow its examples:

#include "clipboard.hpp"
#include <string>

int main() {
    clipboardxx::clipboard clipboard;

    // copy
    clipboard << "text you wanna copy";

    // paste
    std::string paste_text;
    clipboard >> paste_text;
}

Related