The ones who are crazy enough to think they can change the world are the ones who do.- Steve Jobs
C programming provides several inbuilt functions for string to make our programming crystal clear because several lines of coding will be reduced to a word by using standard inbuilt string functions. The definitions for all inbuilt functions in c are written in #include<string.h> library.
Return Type | Function Call | Purpose |
---|---|---|
char * | strcat(str1,str2) | To concatenate or join str2 with str1. |
char * | strncat(str1,str2,n) | Concatenate at most n characters of string str2 to string str1, terminate with '\0' and returns str1. |
char * | strchr(st,ch) | To find the first occurrence of a character ch in a string st. |
char * | strrchr(st,ch) | To find the last occurrence of a character ch in a string st. |
char * | strcpy(str2,str1) | To copy a string from str1 to str2. |
char * | strncpy(str1,str2,n) | Concatenate at most n characters of string str2 to string str1, terminate with '\0' and return str1. |
size_t | strlen(str1) | Returns length of a string str1. |
char * | strstr(str1,str2) | Returns a string str2 if it is present in string str1. If not retruns NULL |
char * | strpbrk(str1,str2) | To print the string str1 from the first occurrence of any one of the given individual character in str2. |
char * | strerror | Return "No error" if a file is found else throw a error message. |
char * | strlwr(str) | To convert upper case letters in a string str to lower case letters. |
char * | strupr(str) | To convert lower case letters in a string str to upper case letters. |
char * | strdup(str) | To duplicate a string str. |
char * | strtok(str, chr) | To replace a symbol char with '\n'(new line) in a string str. |
int | strcmp(str1,str2) | Compare str1 and str2 and return -1 if str1<str2, 0 if str1 == str2 or +1 if str1>str2. |
int | stricmp(str1,str2) | Same as strcmp(str1, str2) but stricmp(str1, str2) is case insensitive. |
int | strncmp(str1,str2,n) | Compare at most n characters of string str1 to string str2 and return -1 if str1<str2, 0 if str1==str2 or +1 if str1>str2. |
int | strnicmp(str1,str2,str3) | Same as strncmp(str1,str2,n) but strnicmp(str1,str2,str3) is case insensitive |
int | strspn(str1,str2) | Return length of prefix of str1 consisting of characters in str2. |
int | strcspn(str1,str2) | Return length of perfix of str1 consisting of characters not in str2. |
char * | strrev(str1) | To reverse the source string str1. |
char * | strset(str1,char) | To replace a string str1 with specified character char. |
char * | strnset(str1,char,n) | To replace a string str1 with specified character char up to specified length n. |
char * | strswab(str1) | Swapping adjacent characters in a string str1 consecutively. |
void * | memcpy(str1,str2,n) | Copy n characters from str2 to str1 and return str1. |
void * | memmove(str1,str2,n) | Copy n characters from str2 to str1 , and return str1. It works even if the object overlap. |
int | memcmp(str1,str2,n) | Compares the first n characters of str1 with str2 and returns as with strcmp. |
void * | memchr(str1,chr,n) | Return a string str1 from a character chr if a character chr present in a string str1 within a length n else return null. |
void * | memset(str1,chr,n) | Place character chr into first n characters of a string str1 and return str1. |
We may make mistakes(spelling, program bug, typing mistake and etc.), So we have this container to collect mistakes. We highly respect your findings.
© Copyright 2019