Solved

TC's nuts

Posted on 1998-10-20
8
227 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
Comment Utility
could you be a little more specific?
0
 

Author Comment

by:cjun
Comment Utility
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
Comment Utility
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
Comment Utility
How do you know it doesn't match condition3?
How do you know it steps into statement2?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Expert Comment

by:Bonev
Comment Utility
Try to build it with all optimizations disabled.

0
 
LVL 1

Expert Comment

by:prozak
Comment Utility
Are you using "=" instead of "=="?
0
 
LVL 10

Accepted Solution

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

Author Comment

by:cjun
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
stack 22 155
Goodbye, so long 10 91
Change to the struct 72 191
How do I avoid pointer to integer casting errors in C programming? 4 190
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…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
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.

771 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

12 Experts available now in Live!

Get 1:1 Help Now