Process returned -1073741819 (0xC0000005) Error when compiling C++ Clock

0

I am trying to make a digital clock.

I understand that the error message is due to a memory problem. My Build log don't show no error.

I have successfully included the libbgi.a as a linked library and the -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32 as linker options.

What may me do to fix it?

#include <graphics.h>
#include <time.h>

int main()
{
    int gd = DETECT, gm;
    char driver[] = "C:\\TC\\BGI";
    initgraph(&gd, &gm, driver);

    time_t rawTime;
    //Created a pointer variable of tm struct. Variable name is currentTime.
    struct tm * currentTime;
    char a[100];

    while(1)
    //Always true
    {
        //%I=%DD, %M=%D, %S=%C;

        rawTime = time(NULL);
        currentTime = localtime(&rawTime);
        strftime(a, 100, "%I:%M:%S", currentTime);
        //function copies the third value, see: 'S', into the first argument ("a").
        //a holds the value %I:%M:%S".
        //%I will be replaced by Hour in 12h format (01-12).
        //%M will be replaced by Minute (00-59).
        //%S will be replaced by Second (00-61).
        //'100' is the maximum number of characters to be copied to 'a'.
        setcolor(11);
        settextstyle(3, HORIZ_DIR, 10);
        outtextxy(200, 100, a);
        //see: color, location.

        strftime(a, 100, "%p", currentTime);
        settextstyle(3, HORIZ_DIR, 2);
        outtextxy(600, 8, a);

        delay(1000);

    }

    strftime(a, 100, "%a, %d %b, %Y", currentTime);
    settextstyle(3, HORIZ_DIR, 5);
    outtextxy(130, 310, a);

    //%p format is for AM or PM designation.
    //%a format specifier is for abbreviated weekday name. Ex: Mon, Tue, Wed etc...
    //%d format specifier is for the day of the month (1-31).
    //%b format specifier is for abbreviated month name. Ex: Jan, Feb, mar etc...
    //%Y formate specifier is for the year Ex: 2015.

    getch();
    closegraph();
}

Expected a beautiful digital clock face for me to edit. Now, I see:

Process returned -1073741819 (0xC0000005)   execution time : 1.849 s
Press any key to continue.
c++
compilation
codeblocks
bgi
winbgi
asked on Stack Overflow Sep 17, 2019 by JamSos • edited Sep 17, 2019 by genpfault

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0