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 |
| |||
| 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 | |
| |
LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/software-testing/2644-how-can-do-test-pointers-structures.html | |||
| Posted By | For | Type | Date |
| Discussweb IT Community - Web Development, Software Programming, SEO, Quality Assurance, 3D, Web Hosting and more... | This thread | Refback | 07-24-2007 11:48 PM |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| 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 |
| How can I allocate arrays or structures bigger than 64K? | vadivelanvaidyanathan | C and C++ Programming | 1 | 07-17-2007 02:33 AM |
| Difference of Structures and Classes | vigneshgets | C and C++ Programming | 1 | 05-24-2007 10:53 AM |