Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Wild pointers in C

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 933
    Comment on it

    Wild pointers

    The pointers which are not initialized and are pointing to some random location are wild pointers. Pointers pointing to a known defined variable are not wild pointers but if it is pointing to a value or a set of values without value being assigned to a variable then pointer is referred to as wild pointer. Wild pointers causes a program to crash abruptly or program not behave properly as expected in short behave badly.

    Example of Wild pointer:

    int main()
    {
      /* wild pointer */
      int *p;  
    /*assigning value to p makes it point to unknown memory location and location becomes corrupted. */
      *p = 12; 
    }

     

    Avoiding wild pointer:

    int main()
    {
       int *p = malloc(sizeof(int));
      *p = 12; /* This is fine (assuming malloc doesn't return NULL) */
    }

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: