Front-end Tutorials

Front-end Tutorials

HTMLCSSSassJavaScriptReactJS
CMS Tutorials

CMS Tutorials

WordPress
Tutorials expand

C String Functions

Posted in C Tutorial
Updated on Feb 05, 2024
By Mari Selvan
👁️ 498 - Views
⏳ 4 mins
💬 1 Comment
C String Functions

Photo Credit to CodeToFun

What is C String Functions?

C string functions are a set of functions available in the C programming language that are specifically designed to work with strings.

A string in C is an array of characters terminated by a null character ('\0').

List of C String Functions

In C programming, there is a standard library called <string.h> that provides several built-in string functions.

Here is a list of commonly used string functions in C:

TagsDescription
strcat()Appends the source string to the destination string.
strncat()Appends the source string to the destination string up to the specified length.
strcpy()Copies a string from source to destination.
strncpy()Copies a string from source to destination up to the specified length.
strlen()Determines the length of the given string.
strcmp()Compares the characters of two strings (This function discriminates between lower case and upper case).
strncmp()Compares the characters of two strings up to the specified length (This function discriminates between lower case and upper case).
stricmp()Compares the characters of two strings (This function doesn't discriminates between lower case and upper case).
strchr()Determines the first occurrence of the given character in the string.
strrchr()Determines the last occurrence of the given character in the string.
strstr()Determines the first occurrence of a given string in another string.
strdup()Duplicates a given string at the allocated memory which is pointed by a pointer variable.
strlwr()Converts any string to a lower case.
strupr()Converts any string to a upper case.
strrev()Reverses all characters of a given string.
strset()Replaces every character of a string with the symbol given by the programmer.
strnset()Replaces every character of a string with the symbol given by the programmer up to the specified length.
strtok()Breaks string into a series of tokens using the given delimiter.
strerror()Translates the error code to a suitable string that describes the error.
strpbrk()Searches the first occurrence of the character in a given string and then it displays the string starting from that character.
strcoll()Compares two strings depends upon the LC_COLLATE settings.
strspn()Finds up to what length two strings are identical.
strcspn()Scans string 1 for the first occurrence of any of the characters that are part of string 2.
strxfrm()Transforms the first n characters of source string into current locale and place them in destination string.
memchr()Searches for the first occurrence of the character in a specified number of characters.
memmove()Copies a block of memory from a location to another using an intermediate buffer.
memcpy()Copies a block of memory from a location to another without using an intermediate buffer.
memcmp()Compares the first n bytes of memory area str1 and memory area str2.
memset()Replaces every character of a string with the symbol given by the programmer up to the specified length.

These are some of the most commonly used string functions in C.

It's worth noting that the above list is not exhaustive, and there are additional string functions and variations available in different C libraries or implementations.

👨‍💻 Join our Community:

To get interesting news and instant updates on Front-End, Back-End, CMS and other Frameworks. Please Join the Telegram Channel:

Author

author
👋 Hey, I'm Mari Selvan

For over eight years, I worked as a full-stack web developer. Now, I have chosen my profession as a full-time blogger at codetofun.com.

Buy me a coffee to make codetofun.com free for everyone.

Buy me a Coffee

Share Your Findings to All

Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Mari Selvan
Mari Selvan
3 months ago

If you have any doubts regarding this article (C String Functions), please comment here. I will help you immediately.

We make use of cookies to improve our user experience. By using this website, you agree with our Cookies Policy
AgreeCookie Policy