Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Access violation???

Reply
Thread Tools

Access violation???

 
 
ofranko
Guest
Posts: n/a
 
      01-07-2009
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 );
}
 
Reply With Quote
 
 
 
 
ofranko
Guest
Posts: n/a
 
      01-07-2009
On Jan 7, 7:57*am, ofranko <(E-Mail Removed)> wrote:
> 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
*/

 
Reply With Quote
 
 
 
 
ofranko
Guest
Posts: n/a
 
      01-07-2009
On Jan 7, 9:11*am, Victor Bazarov <(E-Mail Removed)> wrote:
> ofranko wrote:
> > [..]
> > 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
> --
> Please remove capital 'A's when replying by e-mail
> I do not respond to top-posted replies, please don't ask


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 ..
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Very annoying error: Access to the path is denied. ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity Jay ASP .Net 2 08-20-2007 07:38 PM
403 Forbidden: You were denied access because: Access denied by access control list Southern Kiwi NZ Computing 6 03-19-2006 05:19 AM
one computer can access shared files the other can't even access =?Utf-8?B?SiBIYW1lcg==?= Wireless Networking 4 12-07-2004 03:13 AM
Desktop can't access Laptop but Laptop can access desktop =?Utf-8?B?Qmx1Y2FkZHk3MQ==?= Wireless Networking 2 11-23-2004 01:52 AM
How do I let people access the internet via an access point but not allow them access to my network yar Wireless Networking 4 09-21-2004 03:48 AM



Advertisments