Solved

TC's nuts

Posted on 1998-10-20
8
229 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
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
 
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

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…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now