Reputation: 2192
I am trying to clear the clipboard using the system command. So I have the following code in my application(written in C on Mac 10.6) -
SYSTEM("/bin/echo -n '' | /usr/bin/pbcopy");
but the above line does not clear the clip board. Interestingly, if I run the following command in the Terminal, it does clear the clipboard.
/bin/echo -n '' | /usr/bin/pbcopy
Any idea why System is behaving strangely.
Upvotes: 2
Views: 2471
Reputation: 16861
You're doing way too much work. There's no need to fork a shell and two more processes to do this:
[[NSPasteboard generalPasteboard] clearContents];
Upvotes: 2