String  Functions

Strings Function

Here’s a table of some commonly used string functions in C, along with a brief description of what they do:

Function    Description

strlen()      :Returns the length of a string, not including the terminating null character.

strcpy():Copies a string from one location to another.

strncpy():Copies a specified number of characters from one string to another.

strcat():Appends one string to the end of another.

strncat():Appends a specified number of characters from one string to another.

strcmp():Compares two strings and returns an integer that indicates their relative order.

strncmp():Compares a specified number of characters in two strings and returns an integer that indicates their relative order.

strchr():Returns a pointer to the first occurrence of a specified character in a string.

strrchr():Returns a pointer to the last occurrence of a specified character in a string.

strstr():Returns a pointer to the first occurrence of a specified substring in a string.

Memory Address

In C programming language, a memory address is a unique identifier for a location in memory. Every variable in a C program is stored in a specific memory address. We can use pointers in C to store and manipulate memory addresses.

We can use the  & operator to get the memory address of a variable:

				
					int x = 10;
 int *p = &x;          // p now stores the memory address of x 

				
			

In this example, we declare an integer variable x and initialize it to 10. We then declare a pointer p to an integer and set it to the memory address of x using the  & operator.

We can use the * operator (called the “dereference operator”) to access the value stored at a memory address:

Join To Get Our Newsletter
Spread the love