By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,303 Members | 1,627 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,303 IT Pros & Developers. It's quick & easy.

Exception class EAccessViolation

P: 1
Hi

i got an Access Violation error with AnsiStrings n char*.

First chance exception at $7C812A5B. Exception class EAccessViolation with message 'Access violation at address 0040467E in module 'Serial.exe'. Write of address 0518F503'. Process Serial.exe

the code is here:

Expand|Select|Wrap|Line Numbers
  1. AnsiString temp = Hex2Ascii(APDUCmd, index);
  2.  
  3. AnsiString Hex2Ascii(char *Hex, unsigned int HexLen)
  4. {
  5.     char *AsciiChar = "0";
  6.     AnsiString temp;
  7.     Hex2Ascii(Hex, AsciiChar, HexLen);
  8.     temp = AsciiChar;
  9.     return temp;
  10. }
actually i hav another Hex2Ascii function:
Expand|Select|Wrap|Line Numbers
  1. AnsiString Hex2Ascii(AnsiString HexAnsi, unsigned int HexLen)
  2. {
  3.     char *AsciiChar = "0";
  4.     char *HexChar = HexAnsi.c_str();
  5.     AnsiString temp;
  6.     Hex2Ascii(HexChar, AsciiChar, HexLen);
  7.     temp = AsciiChar;
  8.     return temp;
  9.  
  10. }
APDUCmd is a char array:
Expand|Select|Wrap|Line Numbers
  1. char APDUCmd[261];
if i call Hex2Ascii with array length less than 53, it calls AnsiString Hex2Ascii(AnsiString HexAnsi, unsigned int HexLen) and no error.
if greater than or equal 53, it calls AnsiString Hex2Ascii(char *Hex, unsigned int HexLen) and Access Violation error occurs.

Can anyone help me solve this?
Feb 23 '07 #1
Share this Question
Share on Google+
1 Reply


sicarie
Expert Mod 2.5K+
P: 4,677
Hi

i got an Access Violation error with AnsiStrings n char*.

First chance exception at $7C812A5B. Exception class EAccessViolation with message 'Access violation at address 0040467E in module 'Serial.exe'. Write of address 0518F503'. Process Serial.exe

the code is here:

Expand|Select|Wrap|Line Numbers
  1. AnsiString temp = Hex2Ascii(APDUCmd, index);
  2.  
  3. AnsiString Hex2Ascii(char *Hex, unsigned int HexLen)
  4. {
  5.     char *AsciiChar = "0";
  6.     AnsiString temp;
  7.     Hex2Ascii(Hex, AsciiChar, HexLen);
  8.     temp = AsciiChar;
  9.     return temp;
  10. }
actually i hav another Hex2Ascii function:
Expand|Select|Wrap|Line Numbers
  1. AnsiString Hex2Ascii(AnsiString HexAnsi, unsigned int HexLen)
  2. {
  3.     char *AsciiChar = "0";
  4.     char *HexChar = HexAnsi.c_str();
  5.     AnsiString temp;
  6.     Hex2Ascii(HexChar, AsciiChar, HexLen);
  7.     temp = AsciiChar;
  8.     return temp;
  9.  
  10. }
APDUCmd is a char array:
Expand|Select|Wrap|Line Numbers
  1. char APDUCmd[261];
if i call Hex2Ascii with array length less than 53, it calls AnsiString Hex2Ascii(AnsiString HexAnsi, unsigned int HexLen) and no error.
if greater than or equal 53, it calls AnsiString Hex2Ascii(char *Hex, unsigned int HexLen) and Access Violation error occurs.

Can anyone help me solve this?
In your recursive call, you pass it three variables (HexChar, AsciiChar, HexLen), instead of the two that are declared. Other than that, I'm not too sure what might be going on there... Anyone else have an idea?
Feb 23 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.