Solved

TC's nuts

Posted on 1998-10-20
8
233 Views
Last Modified: 2010-04-15
Recently I programmed codes with turbo c++ 3.0,but something
happened very strange,the sequence in some place may reverse and,it can go into the statement coercively although
the condition isn't reached.
help me
0
Comment
Question by:cjun
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1253704
could you be a little more specific?
0
 

Author Comment

by:cjun
ID: 1253705
The codes included one main file and one procedure set file,error often occurs in the latter.
Now I set an example :
  bool waitstatus(unsigned int status)
  if (condition1)
  {
    while(condition2)
     {
       statement1;
       if(condition3)
       {
        statement2;
       }    
      }
     }
    }
when matching condition2,it goes to condition3 judging,although it doesn't match condition3,it still steps into statement2.my lenghth of the code is total to 800 lines,and
I defined more than 30 char * varieble in it.Of course,some strange phenomenas occur
in even static char *.Why?
0
 
LVL 3

Expert Comment

by:NullTerminator
ID: 1253706
You need to post a sample of the code that shows the behavior.  Your sample is to vague to judge.

You mentioned many char * variables.  Are they all pointing to valid space.  Are you overrunning the bounds of the character arrays?

'\0'
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 84

Expert Comment

by:ozo
ID: 1253707
How do you know it doesn't match condition3?
How do you know it steps into statement2?
0
 
LVL 1

Expert Comment

by:Bonev
ID: 1253708
Try to build it with all optimizations disabled.

0
 
LVL 1

Expert Comment

by:prozak
ID: 1253709
Are you using "=" instead of "=="?
0
 
LVL 10

Accepted Solution

by:
rbr earned 200 total points
ID: 1253710
Pls give more info about your code!
0
 

Author Comment

by:cjun
ID: 1253711
I now can I'd handled this bug.Because I'd a bad custom that always move string point
and never recover it,so I think it's the problem.for example:
/*the wrong way*/
char *test,*des;
 test=test+9;
 strcpy(des,test);


--------------
/*the right way is:*/

char *test,*des;
test=(char *)malloc(4000);
des=(char *)malloc(3000);
strcpy(des,test+9);

---and it's the right action,be careful when you use string point.
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

636 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