Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7630331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:04:33+00:00 2026-05-31T06:04:33+00:00

I am having a funny with my C++ managed code with visual 2008. I

  • 0

I am having a funny with my C++ managed code with visual 2008. I am sure there is a simple reason for this to happen but I am just missing it and getting a bit frustrated here.

The problem:
I am using a XOR to evaluate a checksum of a transmitted sentence. Well, it works flawless in debugging and if I run from visual as release but when I build the installer and install the release, in the same machine, the XOR behave totally differently giving me different values. ie in debugging it gives me 44 and in installed version it gives me 79E721FC.

The code:

{
  String^ OrigChecksum=mysentence->Substring(mysentence->IndexOf('*')+1);
  if(mysentence->StartsWith("!"))
  {
    mysentence=mysentence->Substring(mysentence->IndexOf('!')+1,mysentence->IndexOf('*')-mysentence->IndexOf('!')-1);
  }
  else if(mysentence->StartsWith("$"))
  {
    mysentence=mysentence->Substring(mysentence->IndexOf('$')+1,mysentence->IndexOf('*')-mysentence->IndexOf('$')-1);
  }
  int checksum;
  if(mysentence->Length>1)
  {
    for(int i=0;i<mysentence->Length;i++)
    {
      try
     {
       checksum ^= Convert::ToByte(mysentence[i]);
       //MessageBox::Show(Convert::ToByte(mysentence[i]).ToString("X2"));
      }
      catch(...)
      {
      }

    }
    String^ strChecksum=checksum.ToString("X2");
    //MessageBox::Show(OrigChecksum+","+strChecksum+","+checksum);

    if(OrigChecksum==strChecksum)
    {
      return true;
    }
    else
    {
     return false;
    }
  }
  else
  {
  return false;
  }
}

Note the MessageBox that I am using to see the values when installed as I cannot use the debugger there and when I debug in Visual studio everything is perfect…
I have tried another approach with same results as follow:
using a char array
array^character=mysentence->ToCharArray();
and using the operator ^ instead
checksum=checksum ^ int(character[num])

Did anyone have a similar experience?
Please, any advice or light on this?

All the best Adam

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T06:04:34+00:00Added an answer on May 31, 2026 at 6:04 am

    int checksum; is never initialised, so attempting to xor with it invokes undefined behaviour.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having a heckuva time with this one, though I feel I'm missing something obvious.
I'm having a problem similar to [this question][1] https://stackoverflow.com/questions/1449072/debugging-problem-in-x-code-iphone-development I have created an application,
My wordpress blog is having issues with syntax highlighter evolved plugin, and there's this
I just watched this funny YouTube Video about unit testing (it's Hitler with fake
I'm doing a simple redirect after calling OAuth2::retrieveAccessToken() with Play Framework. I'm having funny
I am having a funny situation which I am not sure if it is
ok am having a funny problem here, scenario is like this: Intent i of
Having been a PHP developer on LAMP servers for quite a while, is there
Having a problem getting a TreeView control to display node images. The code below
Having programmed through emacs and vi for years and years at this point, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.