by Dinesh Thakur Category: Function and Pointer

We can use typecast operator to convert the type of value returned by a pointer dereference expression to another suitable type. For example, if pa is a pointer to a variable a of type int, we can use typecast as (double) *pa to convert the integer value of *pa to type double.

 
by Dinesh Thakur Category: Function and Pointer

We have seen that a function can be called from another function. In fact, the C language allows a function to be called from within itself. Such a function is called a recursive function.

 
by Dinesh Thakur Category: Function and Pointer

This program defines a function named func which has two parameters, a and b of type int. Within its body, this function first prints these parameter values, initializes them to 30 and prints them again. The main function declares two variables, a and b of type int. It first prints the values of these variables and then calls the function func with variables a and b as its arguments. Finally, the main function prints the values of variables a and b again.

 
by Dinesh Thakur Category: Function and Pointer

Another commonly required string operation is that of converting the case of a given string. The C standard library does not provide any function for case conversion. However, some C implementations provide the strlwr and strupr functions. The strlwr function converts all characters in a given string to lowercase, whereas the strupr function converts all characters to uppercase. Typical calls to these functions take the following forms:

 
by Dinesh Thakur Category: Function and Pointer

The clock function is used to determine the processor time in executing a program or part of a program. The header file <time.h> should be included in the program for its application. The function prototype is given below.

 
by Dinesh Thakur Category: Function and Pointer

The length of a string is defined as the number of characters in it excluding the null terminator. The strlen function returns the length of a specified string. A typical call to this function takes the following form:

 
by Dinesh Thakur Category: Function and Pointer

It accepts three parameters  x,y, and z, each of type double and returns a value of type double.

 
by Dinesh Thakur Category: Function and Pointer

A function definition comprises a head (or header) and a body. The header gives the information about type of function, name of function, and a list of parameters. The list of parameters comprises types and names of parameters enclosed in parentheses and separated by commas. An illustration of function definition is given below.



 
by Dinesh Thakur Category: Function and Pointer

The values of pointer variables are unsigned integer numbers which are addresses of other variables. An unsigned integer is allocated 4 bytes of memory for its storage on a typical 32-bit system. Thus, pointers to all types of data occupy the same size of memory because the value of a pointer is the memory address - an unsigned integer. However, the variables to which the pointers point to, of course, occupy different sizes of memory blocks according to their types.

 
by Dinesh Thakur Category: Function and Pointer

A standard C header file contains the declarations or prototypes of functions of a particular category. A function 'prototype usually specifies the type of value returned by that function, the function name and a list specifying parameter types as

 

Page 4 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