![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| will this script in crontab effect SUN 9?? | thepurple | SUN Solaris | 2 | 10-05-2007 05:31 AM |
| Temporarily disable effect of set -e in ksh | ugeek | Shell Programming and Scripting | 1 | 03-28-2007 05:21 AM |
| How do properties effect script? | Chiefos | UNIX for Dummies Questions & Answers | 1 | 06-21-2006 07:23 AM |
| Effect of Preemptive Kernel | sriram.ec | UNIX for Advanced & Expert Users | 2 | 03-15-2006 01:43 AM |
| recursive effect!! | sskb | UNIX for Dummies Questions & Answers | 2 | 01-30-2003 12:05 PM |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
||||
|
strange effect: if ... else in C influence a previous statement
I write a short code in c
it may work well, but when I add an if ... else ... structure, a computation before the structure can not give a correct result compilation and run can do well, but the result is wrong. Very strange (1) y2 = expression; //y2 = 0 always 0 error ................. add : if(a->is_root) c = m2 - y2; else f = m2 - y2; (2) y2 = expression; //y2 = 0 always 0 error ................. add : if(a->is_root) c = m2 - y2; if(!a->is_root) f = m2 - y2; (3) y2 = expression; // y2 = normal value; normal ................. add : //if(a->is_root) c = m2 - y2; if(!a->is_root) f = m2 - y2; (4) y2 = expression; // y2 = normal value; normal ................. add : if(a->is_root) c = m2 - y2; //if(!a->is_root) f = m2 - y2; (5) y2 = expression; // y2 = normal value; normal add : //if(a->is_root) c = m2 - y2; //if(!a->is_root) f = m2 - y2; Trouble: can not use if... else ... normally Question: (1) if... else ... can influence a previous statement, why? (2) How to solve the problem? Last edited by cdbug; 11-20-2008 at 05:38 AM.. |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|