In this article. The key to writing the declaration for a function pointer is that you're just writing out the declaration of a function but with (*func_name) where you'd normally just put func_name. How to use pointers … When first ending parenthesis encounters then go left. The C programming language lacks a string variable, but it does have the char array, which is effectively the same thing. While declaring the pointer, same guidelines and rules should be followed for pointer_name as given for variable_name in variable declaration. (Similarly, a declaration like int *x can be read as *x is an int, so x must be a pointer to an int.) C Pointer [22 exercises with solution] 1. Example of integer; int *ptr; Here int is the data_type of pointer and ptr is the name of pointer. Just like another pointer variable declaration, a structure pointer can also be declared by preceding asterisk (*) character. A variable declared as a pointer holds a memory address. It’s a much more interesting topic than messing with numeric arrays. A pointer declaration names a pointer variable and specifies the type of the object to which the variable points. Pointer variable declaration follows almost similar syntax as of normal variable. Syntax to declare pointer variable data-type * pointer-variable-name; data-type is a valid C data type. * symbol specifies it is a pointer variable. Let us see the steps to read complicated declarations. A pointer type declaration takes one of the following forms: type* identifier; void* identifier; //allowed but not recommended The type specified before the * in a pointer type is called the referent type. Only an unmanaged type can be a referent type. Syntax. pointer declaration, initialization and accessing with the help of example Reading Function Pointer Declarations The syntax is: struct structure_name *strcuture_pointer_variable; Here, the language authors preferred to make the syntax variable-centric rather than type-centric. Go to the editor Expected Output:. Write a program in C to show the basic declaration of pointer. I explain this in my answer to Why was the C syntax for arrays, pointers, and functions designed this way?, and it basically comes down to:. You must prefix * before variable name to declare it as a pointer. Declaration of structure pointer. A pointer to function is declared with the * ,the general statement of its declaration is: return_type (*function_name)(arguments) You have to remember that the parentheses around (*function_name) are important because without them, the compiler will think the function_name is returning a pointer … 2) To convert expression to postfix, start from innermost parenthesis, If innermost parenthesis is not present then start from declarations name and go right first. declarator: pointer opt direct-declarator direct-declarator: identifier (declarator) direct-declarator [constant-expression opt] direct-declarator (parameter-type-list) where specifies that it is pointer variable. 1) Convert C declaration to postfix format and read from right to left. As an array, a string in C can be completely twisted, torqued, and abused by using pointers.