by Dinesh Thakur Category: Function and Pointer

So far we have studied functions that either return a value or have a void return type. A function can also return a pointer to a data item of any type. However, we must be careful while returning pointers from a function. A common mistake would be to return a pointer to a local variable or value parameter in that function as they are destroyed when control returns to the calling function.

 
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

 
by Dinesh Thakur Category: Function and Pointer

We have studied that an array is a powerful built-in data structure in the C language. It is a collection of data items of the same type stored in consecutive memory locations. An element of an array can be accessed using subscript notation, as in a [i ] , b [ i ] [ j ] , etc. Also, we can process entire arrays using loops and pass them to functions.

 
by Dinesh Thakur Category: Function and Pointer

Random number generation is a very useful facility in many programming situations, particularly gaming and simulation. We can also use it to generate test data for programs, particularly when a large amount of data is required. This saves a lot of time on data entry.

 
by Dinesh Thakur Category: Function and Pointer

The trigonometric and hyperbolic functions provided in the standard mathematical library are listed in Table. Except for the atan2 function, which takes two arguments, all other functions take a single argument and each function returns a single value. Note that the function parameters and return values are of type double.

 
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

String concatenation is another basic string manipulation operation. In this, all the characters in a string, including the null terminator, are appended to the target string (i. e., copied at the end) replacing the null terminator in it. Thus, after the concatenation operation, the target string contains all the characters originally contained in it followed by those in the appended string. For example, if string sl contains "Pine" and string s2 contains "apple", then appending string s2 to sl modifies string sl to "Pineapple". Note that sl must have enough character positions to accommodate all the appended characters, including the null terminator.

 
by Dinesh Thakur Category: Function and Pointer

Sometimes we may want that a function should not modify the value of a parameter passed to it, either directly within that function or indirectly in some other function called form it. This can be achieved using const parameters. Consider, for example, the function given below to calculate the sum of the first n integer numbers.

 
by Dinesh Thakur Category: Function and Pointer

We know that when a function is called, the parameters are passed to it by value, i.e., the values of arguments in a function call are copied to the parameters of the called function. Since a function parameter is a copy of the argument variable and is local to the function, any change in its value in the body of the function modifies only the local copy and not the corresponding argument in the calling function.

 

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