I'm a new learner of C language. Can someone help me understand some concepts? What's the use of Pointers in C?
Pointers have many uses in C. They're required for some library functions. A pointer is the address that a value is stored at. You'll frequently see an asterick in front of a pointer's name. That derefences the pointer. In English, it returns the value stored at the address that the pointer points to. An ampersand preceding a variable's name returns the variable's address instead of it's value int var; int *pointer; var = 2; pointer = &var; /* assign var's address to pointer */ printf( "%d\n", pointer ); /* prints 2 */ printf( "%d\n", &var ); /* prints 2 */ if( var == *pointer ) /* is true. The asterick gets the value pointer points to */
Join our real-time social learning platform and learn together with your friends!