A NULL
pointer points to memory that doesn’t exist. This may be address 0x00000000
or any other implementation-defined value (as long as it can never be a real address). Dereferencing it means trying to access whatever is pointed to by the pointer. The *
operator is the dereferencing operator:
int a, b, c; // some integers int *pi; // a pointer to an integer a = 5; pi = &a; // pi points to a b = *pi; // b is now 5 pi = NULL; c = *pi; // this is a NULL pointer dereference
This is exactly the same thing as a NullReferenceException
in C#, except that pointers in C can point to any data object, even elements inside an array.
Related Posts:
- Warning: assignment from incompatible pointer type
- Returning an array using C
- Why do I get “cast from pointer to integer of different size” error?
- Excess elements of scalar initializer for pointer to array of ints
- Realloc Invalid Pointer in C
- Pointer to 2D arrays in C
- Pointer to a string in C?
- Using pointer to char array, values in that array can be accessed?
- Arrow operator (->) usage in C
- What does “dereferencing” a pointer mean?
- char *array and char array[]
- What is the difference between const int*, const int * const, and int const *?
- What does ** do in C language?
- Invalid pointer error on invoking free() after malloc in C
- expression must have integral type
- How do you pass a function as a parameter in C?
- How do you pass a function as a parameter in C?
- C free(): invalid pointer
- What’s wrong with my code? What is argv[1]?
- Valgrind: Invalid read of size 1
- Warning: return from incompatible pointer type in C
- How to do scanf for single char in C
- Break statement not within loop or switch in C
- How to properly malloc for array of struct in C
- Cache Simulator in C
- strcmp giving segmentation fault
- Where is the C auto keyword used?
- Why am I getting this error: “data definition has no type or storage class”?
- Initialization from incompatible pointer type warning when assigning to a pointer
- Typedef function pointer?
- Convert char array to a int number in C
- Bind failed: Address already in use
- Warning/error “function declaration isn’t a prototype”
- How to prevent multiple definitions in C?
- How to pass 2D array (matrix) in a function in C?
- How can you print multiple variables inside a string using printf?
- warning: passing argument ’from incompatible pointer type [enabled by default]’
- C dynamically growing array
- Why should we check WIFEXITED after wait in order to kill child processes in Linux system call?
- How to compile makefile using MinGW?
- Mapping a numeric range onto another
- Why are hexadecimal numbers prefixed with 0x?
- too many arguments for format [-Wformat-extra-args]
- What is the difference between char array and char pointer in C?
- How to convert const char* to char* in C?
- How to copy a char array in C?
- cast to pointer from integer of different size, pthread code
- Invalid type argument of unary ‘*’ (have ‘int’) Error in C
- C subscripted value is neither array nor pointer nor vector when assigning an array element value
- error: too few arguments to function `printDay’ (C language)
- Why use pointers?
- Where to find the complete definition of off_t type?
- struct has no member named
- printf not printing to screen
- Still Reachable Leak detected by Valgrind
- Assembly x86 – “leave” Instruction
- What is signed integer overflow?
- When to use const char * and when to use const char []
- What do numbers using 0x notation mean?
- Can I create an Array of Char pointers in C?
- Does stack grow upward or downward?
- Convert Little Endian to Big Endian
- error C2371: ‘functionname’ redefinition: different basic types
- How does one represent the empty char?
- How to write to a file using open() and printf()?
- note: previous implicit declaration of ‘point_forward’ was here
- Can I define a function inside a C structure?
- Where is the
header file on Linux? Why can’t I find ? - getc() vs fgetc() – What are the major differences?
- Casting a pointer to an int
- typedef struct pointer definition
- Tokenizing strings in C
- Difference between char *argv[] and char **argv for the second argument to main()
- Warning: comparison of distinct pointer types
- Dereference void pointer
- “-bash: gcc: command not found” using cygwin when compiling c?
- How to format strings using printf() to get equal length in the output
- What do \t and \b do?
- Why and when to use static structures in C programming?
- Where does linux store my syslog?
- Example of waitpid() in use?
- Can a function return two values?
- C: warning: excess elements in array initializer; near initialization for ‘xxx’ ; expects ‘char *’, but has type ‘int’
- write() to stdout and printf output not interleaved?
- How to know what the ‘errno’ means?
- Split string with multiple delimiters using strtok in C
- Printf was not declared in this scope
- warning: missing terminating ” character [enabled by default]
- How to free memory from char array in C
- Can I get Unix’s pthread.h to compile in Windows?
- Initializing 2D char array in C
- FFT in a single C-file
- Process exited with return value 3221225477
- How do I check if a string contains a certain character?
- malloc(sizeof(int)) vs malloc(sizeof(int *)) vs (int *)malloc(sizeof(int))
- %p Format specifier in c
- Level vs Edge Trigger Network Event Mechanisms
- “Nothing to be done for makefile” message
- Convert Char to String in C
- What is the difference between signed and unsigned int