by Dinesh Thakur Category: Function and Pointer

The default returns value from a function in int. In other words generally unless explicitly specified the default return value by compiler would be integer value from function. So when a programmer wants other than integer values to be returned from function then it is essential that the programmer takes some steps in doing this namely:

 
by Dinesh Thakur Category: Function and Pointer

We saw that pointer values may be assigned to pointers of same type. However, pointers may be type cast from one type to another type. In the following code lines, A is an int type variable, D is variable of type double, and ch is a variable of type char. Pa is declared as a pointer to int variables, Pd is declared as a pointer to double type variables, and Pc is declared as pointer to character type variables. Pa is assigned the value &A.

 
by Dinesh Thakur Category: Function and Pointer

The main () is a special function that marks the beginning of the program. The type int before main signifies that function main () returns an integer value to the system on its completion.

 
by Dinesh Thakur Category: Function and Pointer

Recall that a function call takes the form

func_ name ( arg_list )

 
by Dinesh Thakur Category: Function and Pointer

exit () is used to exit the program as a whole. In other words it returns control to the operating system.

After exit () all memory and temporary storage areas are all flushed out and control goes out of program. In contrast the return statement is used to return from a function and return control to the calling function.



 
by Dinesh Thakur Category: Function and Pointer

Except a few, most of the programs in C may be written with or without pointers. Then the question arises "Why use pointers if you can do without them?” Pointers are considered to be useful tools in programming because of the following reasons:

 
by Dinesh Thakur Category: Function and Pointer

To manipulate data using pointers, the C language provides two operators: address (&) and dereference (*). These are unary prefix operators. Their precedence is the same as other unary operators which is higher than multiplicative operators.

 
by Dinesh Thakur Category: Function and Pointer

The declaration of a pointer variable in C, comprises the type of pointer followed by indirection operator (*) which is followed by an identifier for the pointer. The declaration is done as follows:

 
by Dinesh Thakur Category: Function and Pointer

Since a pointer to type T is analogous to an array of type T, a pointer to a pointer (T**) is analogous to an array of type T*, i. e., an array of pointers to type T. Each element in this array of pointers can be used further to point to an array of type T. Thus, a pointer to a pointer can be used to represent two-dimensional arrays, as illustrated in Fig.

 

Page 2 of 8

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content







Popular Article