C++ signals Linux

how can do this programs in c++

Program description:
Infinite loop in a program starts working with 2 seconds the screen (console) "I 'm trying" to write, but it automatically after 10 seconds, the screen "Close" will terminate the execution of typing.
c++ code

I couldn't get your English, but I hope this is what you want, basically. This small program prints hello world on the screen after two seconds, for an infinite number of times.

 
#include <iostream>
using namespace std;
int main()
{
        while(1)
        {
                cout << "Hello, world!" << endl;
                sleep(2);
        }
return 0;
}

I hope it helps you

i am sorry
i dont know english very well

programs after 10 seconds will be close automaticaly

my code:

#include <iostream>
#include <signal.h>
#include <unistd.h>
using namespace std;

void timeHandler(int a)
{
cout<<"I 'm trying";
alarm(2);
}
int main()
{
sinal(SIGALRM, timeHandler());
raise(SIGALARM);
while(1);        
return 0;
}

Sorry mate, I am a novice myself, the only help that I could give you for the moment is, check the manual pages of all the functions, you will get all the details to solve your problem. Start by reading the manual page of the signal function, just type

 
man signal

Sorry once again, but don't worry someone would surely come for your help.

Good luck!