Common Mistakes / Errors while using Pointer in C Programming

1 . Assigning Value to Uninitialized Pointer
      int * ptr , m = 100 ;
      *ptr = m ;                 // Error on This Line 

2 . Assigning Value to Pointer Variable
      int * ptr , m = 100 ;
      ptr = m ;                 // Error on This Line 

3 . Not Dereferencing Pointer Variable
      int * ptr , m = 100 ;
      ptr =  &m ;
      printf("%d",p);     // Error on this Line

4. Assigning Address of Un-initialized Variable
      int *ptr,m;
      p = &m;     // Error on this Line

5. Comparing Pointers that point to different objects
       char str1[10],str2[10];
       char *ptr1 = str1;
       char *ptr2 = str2;
       if(ptr1>ptr2)  .....                  // Error Here 

Bookmark & Share


1 comments

  1. Anonymous // April 19, 2025  

    good work! could have been better if you posted the corrections too.

Post a Comment

Your Feedback :This is Growing Site and Your Feedback is important for Us to improve the Site performance & Quality of Content.Feel Free to contact and Please Provide Name & Contact Email