Solved

IF problem in C++

Posted on 2013-07-01
6
217 Views
Last Modified: 2013-07-02
I've a problem with this IF sentence in Visual Studio 2010 C++:
      if (dataAligV!=0)
      {
            objPT=frmPH-objPT;
      }

If I run the program in Debug Mode it works fine and does'nt execute the "objPT=" sentence but in release mode (with the same input data)  it doesn't work.

In release mode, if I add some code to do a txt trace, it also works fine. I know it could be a hard issue to solve, but I would appreciate if anyone can help me.

tks in advance,
Leonel
samplecode.txt
0
Comment
Question by:leorocha
  • 3
  • 2
6 Comments
 
LVL 20

Accepted Solution

by:
n2fc earned 500 total points
ID: 39291668
If the results vary like that, probable cause is an uninitialized variable...

Try setting an initial value for "dataAligV" when you declare it...
0
 
LVL 54

Expert Comment

by:Julian Hansen
ID: 39291781
So you are saying if you put something here
 if (dataAligV!=0)
      {
            objPT=frmPH-objPT;
   // Dump dataAligV here
      }

Open in new window

It works the way you want to?
0
 

Author Comment

by:leorocha
ID: 39291820
Yes, JulianH. Also if no code is inserted but in DEBUG MODE works fine. The problem arises when I build the code in RELEASE MODE. It's hard to solve...

For more info, it is a WIN32 project creating "int __stdcall fnCreateCardEx" and exporting to be used by an VB6 ActiveX. This function do some graphic printing over plastic cards using WINGDI
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:leorocha
ID: 39291823
n2fc, I've checked that a hundred times (but I'will do this again). All variables are initialized.
0
 

Author Closing Comment

by:leorocha
ID: 39293533
tks n2fc, in 101 try I've found the problem. The variable was initialized but not in the correct way in VB6 ActiveX
0
 
LVL 20

Expert Comment

by:n2fc
ID: 39293925
Glad I was able to help!
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need to convert MSDEV 6.0 to Dev Studio 2010 5 31
need some help with Editbox 11 108
Parse a URL key value 4 184
Visual Studio 2015 error "not a valid Win32 application" 6 503
The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question