Access violation???

O

ofranko

i get the following exception. i have no idea where to begin from.
could someone point me to the solution?


Unhandled exception at 0x5c5aa3d7 (msvcr90d.dll) in
addWithObjects1.exe: 0xC0000005: Access violation writing location
0x012888a0.




class TheDate
{
public:
TheDate(char initialDateBuffer[9]);
~TheDate();
char *GetDateBuffer();
void SetDateBuffer(char dateBuffer[9]);
//void DisplayDate(char theDateBuffer[9]);

private:
char theDateBuffer[9];
};

TheDate::TheDate(char initialDateBuffer[9])
{
strncpy_s( theDateBuffer,9, initialDateBuffer,9);
}

TheDate::~TheDate()
{
}

char *TheDate::GetDateBuffer()
{
cout <<"GetDateBuffer()\n";
return theDateBuffer;
}

void TheDate::SetDateBuffer(char dateBuffer[9])
{
_strdate_s( dateBuffer,9);//gets system date

strncpy_s( theDateBuffer,9,dateBuffer ,9 );
}
 
O

ofranko

i get the following exception.   i have no idea where to begin from.
could someone point me to the solution?

Unhandled exception at 0x5c5aa3d7 (msvcr90d.dll) in
addWithObjects1.exe: 0xC0000005: Access violation writing location
0x012888a0.

class TheDate
                {
                public:
                        TheDate(char initialDateBuffer[9]);
                        ~TheDate();
                        char *GetDateBuffer();
                        void SetDateBuffer(char dateBuffer[9]);
                        //void DisplayDate(char theDateBuffer[9]);

                private:
                        char  theDateBuffer[9];
                };

        TheDate::TheDate(char  initialDateBuffer[9])
                {
                 strncpy_s( theDateBuffer,9, initialDateBuffer,9);
                }

        TheDate::~TheDate()
                {
                }

        char *TheDate::GetDateBuffer()
        {
                cout <<"GetDateBuffer()\n";
                return  theDateBuffer;
                }

        void TheDate::SetDateBuffer(char dateBuffer[9])
                {
           _strdate_s( dateBuffer,9);//gets system date

                 strncpy_s( theDateBuffer,9,dateBuffer ,9 );
                }

problem seems to be related to this fx... at _RESET_STRING(buffer,
sizeInChars);


int month, day, year;
SYSTEMTIME dt; /* Win32 time structure */

_VALIDATE_RETURN_ERRCODE( ( buffer != NULL && sizeInChars >
0 ), EINVAL )
_RESET_STRING(buffer, sizeInChars);
_VALIDATE_RETURN_ERRCODE( (sizeInChars >= 9), ERANGE )

GetLocalTime(&dt);
month = dt.wMonth;
day = dt.wDay;
year = dt.wYear % 100; /* change year into 0-99 value
*/
 
O

ofranko

ofranko said:
[..]
problem seems to be related to this fx...  at  _RESET_STRING(buffer,
sizeInChars);
        int month, day, year;
        SYSTEMTIME dt;                  /* Win32 time structure */
        _VALIDATE_RETURN_ERRCODE( ( buffer != NULL && sizeInChars >
0 ), EINVAL )
        _RESET_STRING(buffer, sizeInChars);
        _VALIDATE_RETURN_ERRCODE( (sizeInChars >= 9), ERANGE )
        GetLocalTime(&dt);
        month = dt.wMonth;
        day = dt.wDay;
        year = dt.wYear % 100;          /* change year into 0-99 value
*/

What is '_RESET_STRING'?  Looks like a macro of sorts.  It's not part of
the C++ language proper or the Standard library, so you're going to have
to explain to us what it does before we can help you.  An alternative is
to ask in the newsgroup for your compiler if those things are facilities
supplied by it.

V

i'm sorry for not explaining better... i don't know what it does..
it's a C++ fx related to _strdate_s (i'm guessing) i stepped threw the
code and was brought to this point... i was, just, hoping some one had
seen it before..
that aside, i'm trying diff approach with std::string and without the
char*.... i am hoping this will be more straight forward... i was
using that approach yesterday and someone convinced me i was way
off.... can you direct me to an article or method to get system date
in a win32 c++ console app.

fyi - this is my first c++ program using oop ... i'm in an online
class just starting c++ . ... i am sorry if i ask foolish questions...
ty for your help ..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,991
Messages
2,570,217
Members
46,805
Latest member
ClydeHeld1

Latest Threads

Top