This is a discussion on How can do test the Pointers & Structures? within the Software Testing forums, part of the Software Quality Assurance category; Hi, Any one Explain. Thanks, Sundar Raja...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
#1
| |||
| |||
| Hi, Any one Explain. Thanks, Sundar Raja |
|
#2
| |||
| |||
| we can test whether the pointer is currently valid by checking if it's not equal to the null pointer, or contrariwise, we can test whether it's invalid by checking if it's equal to the null pointer. if(p != NULL) Furthermore, if you write the test if(p != NULL), it does not in the general case mean ``is p valid?''. The test if(p != NULL) can only be used to mean ``is p valid?'' if you have taken care to make sure that all non-valid pointers have been set to null. (There is one condition under which C does guarantee that a pointer variable will be initialized to a null pointer, and that is when the pointer variable is a global variable or a member of a global structure, or more precisely, when it is part of a variable, array, or structure which has static duration.) Remember, too, that the shorthand form if(p) is precisely equivalent to if(p != NULL). So you may be able to read if(p) as ``if p is valid'', but again, only if you've ensured that whenever p is not valid, it is set to null. |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PHP Control Structures | Falcon | PHP Programming | 12 | 07-02-2008 12:17 AM |
| looping structures in Ruby? | vadivelanvaidyanathan | Ruby | 1 | 08-18-2007 12:53 AM |
| What is the difference between structures and enumeration? | anbuchezhians | VB.NET Programming | 1 | 07-28-2007 12:50 AM |
| declare an array of N pointers to functions returning ? | sundarraja | C and C++ Programming | 0 | 07-25-2007 03:58 AM |
| Difference of Structures and Classes | vigneshgets | C and C++ Programming | 1 | 05-24-2007 10:53 AM |
Our Partners |