How am I supposed to take input/catch CTRL+C or CTRL+V commands ?

Recommended Answers

All 4 Replies

Are we talking about manipulating clipboard data or catching command line signals (though I'm not familiar with ctrl+v as a signal)?

Yes, catching command line signal. What I was coding is, user can enter a string untill he/she presses ctrl+c. It will be in command prompt.

You'll need to catch and handle the SIGINT signal:

#include <stdio.h>
#include <signal.h>

volatile sig_atomic_t caught = 0;

void handler(int signum)
{
    caught = 1;
}

int main(void)
{
    signal(SIGINT, handler);

    while (!caught)
        puts("Booger");

    puts("Got it!");
    getchar();

    return 0;
}

Or use getch() :twisted:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.