by Dinesh Thakur Category: Function and Pointer

Given a function f(x) which is continuous in the interval [a, b] and satisfying the property hat f(a)*f(b) < 0, there exists a root of the function f(x) in the interval [a, b]. The bisection algorithm works as follows where t: and 8 are small values specified by the user.

 
by Dinesh Thakur Category: Function and Pointer

We have been writing "return 0;" as the last statement of every main function we have developed so far. But since main is the first function to start, no function calls main. So, the question that arises is - "Where does the return value of main go?" The value is returned and stored by the operating system and can be used to guide further actions by the operating system using shell scripts/batch files.



 
by Dinesh Thakur Category: Function and Pointer

The syntax of the function is as follows:

size_t strftime(char* s, size_t maxsize, const char* format, const struct tm * Tmptr);

 
by Dinesh Thakur Category: Function and Pointer

The syntax of the function asctime () is written as follows:

char * asctime( const stuct tm * Tmptr);

 
by Dinesh Thakur Category: Function and Pointer

The function prototype of ctime () is written in the following manner:

char *ctime( const time_t *Timeptr);

 
by Dinesh Thakur Category: Function and Pointer

The function localtime () converts the calendar time, i.e., the output of function time (), into a broken-down time expressed as local time, and returns the pointer to broken-down time. If the conversion into local time fails, the function returns NULL pointer. The prototype of the function is written in the following manner:

 
by Dinesh Thakur Category: Function and Pointer

The prototype of the function is written as given below,

time_t mktime (struct tm * Timeptr) ;

 
by Dinesh Thakur Category: Function and Pointer

The function difftime ()returns the difference between two calendar times in seconds, i.e., number of seconds elapsed between two calendar times time2 and time]. The calendar time represents the time elapsed since 00:00:00 hours 01 January 1970, GMT. The function returns the difference in seconds as a double number. The function prototype is written as follows:

 
by Dinesh Thakur Category: Function and Pointer

The function time () returns the current calendar time, i.e., the number of seconds elapsed since 00:00:00 hour January 1, 1970 GMT (or gmt are used alternatively) up to the execution of the function. The function prototype is written as follows:

 
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 assignment operator (=) may be used on pointers of the same type. However, if the types of pointers (types of variables to which they point) are not same then we will have to do type casting of one of these to the type of the other to use assignment operator. However, the void pointer (void * ) can represent any pointer type. Thus, any type of pointer may be assigned to a void pointer. However, the reverse is not valid. A void pointer cannot be assigned to any other type of pointer without first converting the void pointer to that type.

 
by Dinesh Thakur Category: Function and Pointer

We may make use of typedef for declaring pointers to functions. Examine the following code:

typedef void(*PF) ();

 
by Dinesh Thakur Category: Function and Pointer

A function may have another function as one of its parameters besides having parameters of other data types. A function is a derived type object; its type is derived from the type of data it returns. Like arrays, the name of a function also holds the address of the function.

 
by Dinesh Thakur Category: Function and Pointer

If elements of an array are two-dimensional arrays, the array is called a three-dimensional array. Therefore, a three-dimensional array may be considered as an array of matrices. Let Arm be a 3-dimensional array or an array of matrices. The declaration of pointer and its initialization is carried out as given below.

 
by Dinesh Thakur Category: Function and Pointer

memchr (): The function searches for first occurrence of c through the first n characters of the string pointed to by S. If successful it returns pointer to c in the string. If not successful, it returns NULL or 0.

 
by Dinesh Thakur Category: Function and Pointer

Passing Arguments by Value

The arguments to a function may be passed on by value or by pointers. In the first case the copies of values of parameters are passed on to the function. The function can only manipulate these copies. So, the original values of parameters are not affected. Their values cannot be changed by the function because function does not know where the parameters are stored in the memory. For example, if the function simply swapped the values of its parameters, it is only swapping the copies of the values of parameters. The original values of parameters are not affected. In Program, the arguments are passed on to the function by values. These values are changed by the function and then an expression is evaluated. The function may be called any numbers of times, the output of the program as well as the data fed to function do not change. This is the benefit of passing the arguments by value.

 
by Dinesh Thakur Category: Function and Pointer

Strings are character arrays terminated by null character. Pointer to a single string may be declared in the same way as the pointer to a one-dimensional array.

 
by Dinesh Thakur Category: Function and Pointer

An individual element of an array may be regarded as a variable of the type declared in the declaration of the array. All the operators that can be applied to a variable of that type are applicable to the elements of array as well. Program, the array elements are subjected to arithmetic operations with the help of pointers.

 

Page 1 of 4



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.



Related Articles