Solved

TC's nuts

Posted on 1998-10-20
8
232 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
Technology Partners: 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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to issue a linefeed, pause, and clear screen in UNIX enviroment 3 85
Grammars for C C++ and java 1 145
Socket Programming (Unix) 8 160
Using ANSI C how to Read a .csv file 10 132
Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

739 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