Jump to content

So i can't google it because i don't know how that process is named, i'll try to describe it.

So as I'm trying to make an "Alarm clock" program I think i need the console window to be active, i mean we "build and run" the program and then lets say that console window displays time (which changes). so the seconds, minutes ant hours change like real clock. And also i'm not sure if i should do it in a console window at all, maybe move on from it?

i5-4690k, R9 380 4gb, 8gb-1600MHz ram, corsair vs 550w, astrock h97m anniversary.

 

Link to comment
https://linustechtips.com/topic/497564-not-sure-how-its-called-c/
Share on other sites

Link to post
Share on other sites

What have you got so far? Have you worked on the sound yet? Or do you need to get the date and time?

    int month, hour, minute;     // get current time    time_t alarm = time(0);    // convert to 'broken time'    tm bt = *localtime(&alarm);    //cout<<"Enter the month (number), hour and minutes"<<endl;    //cin>>month>>hour>>minute;    // extract month number from 'broken time' struct    cout << "month: " << (bt.tm_mon + 1) << '\n';    cout << "hours: " << (bt.tm_hour) << '\n';    cout << "mins : " << (bt.tm_min) << '\n';

For now this. next step i thought would be good to get that "active" console.

For the sound i may just use \a or open up some .mp3

i5-4690k, R9 380 4gb, 8gb-1600MHz ram, corsair vs 550w, astrock h97m anniversary.

 

Link to post
Share on other sites

    int month, hour, minute;     // get current time    time_t alarm = time(0);    // convert to 'broken time'    tm bt = *localtime(&alarm);    //cout<<"Enter the month (number), hour and minutes"<<endl;    //cin>>month>>hour>>minute;    // extract month number from 'broken time' struct    cout << "month: " << (bt.tm_mon + 1) << '\n';    cout << "hours: " << (bt.tm_hour) << '\n';    cout << "mins : " << (bt.tm_min) << '\n';

For now this. next step i thought would be good to get that "active" console.

For the sound i may just use \a or open up some .mp3

add the active console and if want to add the mp3

I think the code is...

{

       PlaySound("c:\\(FILE NAME).mp3",NULL,SND_FILENAME|SND_LOOP|SND_ASYNC);

   

   system("PAUSE");

   return 0;

}

I might be wrong and might be a wav file

Link to post
Share on other sites

add the active console and if want to add the mp3

I think the code is...

{

       PlaySound("c:\\(FILE NAME).mp3",NULL,SND_FILENAME|SND_LOOP|SND_ASYNC);

   

   system("PAUSE");

   return 0;

}

I might be wrong and might be a wav file

Here's what i've done, it works though :D. so Alram Clock v0.1

int month, hour, minute,sec;     // get current time    time_t alarm = time(0);    // convert to 'broken time'    tm clock = *localtime(&alarm);    cout<<"Enter the month (number), hour and minutes"<<endl;    cin>>hour>>minute>>sec;    for(int i=0; i<5000; i++)    {        system("cls");        cout<<clock.tm_hour<<" : "<<clock.tm_min<<" : "<<clock.tm_sec++;        if(clock.tm_sec==60)        {            clock.tm_sec=1;            clock.tm_min++;        }        if(clock.tm_min==60)        {            clock.tm_min=0;            clock.tm_hour++;        }        if(clock.tm_hour==hour && clock.tm_min==minute && clock.tm_sec==sec)           {               system("C:\\temp.mp3");               break;           }       _sleep(1000);    }

i5-4690k, R9 380 4gb, 8gb-1600MHz ram, corsair vs 550w, astrock h97m anniversary.

 

Link to post
Share on other sites

 

Here's what i've done, it works though :D. so Alram Clock v0.1

int month, hour, minute,sec;     // get current time    time_t alarm = time(0);    // convert to 'broken time'    tm clock = *localtime(&alarm);    cout<<"Enter the month (number), hour and minutes"<<endl;    cin>>hour>>minute>>sec;    for(int i=0; i<5000; i++)    {        system("cls");        cout<<clock.tm_hour<<" : "<<clock.tm_min<<" : "<<clock.tm_sec++;        if(clock.tm_sec==60)        {            clock.tm_sec=1;            clock.tm_min++;        }        if(clock.tm_min==60)        {            clock.tm_min=0;            clock.tm_hour++;        }        if(clock.tm_hour==hour && clock.tm_min==minute && clock.tm_sec==sec)           {               system("C:\\temp.mp3");               break;           }       _sleep(1000);    }

Awesome man!

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×