C - String Functions



Arrays and Strings in Tamil


C - String Functions

  • In C- Programming some inbuilt functions are available for manipulating the string.
  • Some of the string functions are listed below as follows :
C String Function

strcat ( )

  • In C-Programming the strcat() function is used for concatenating two given strings.
  • It concatenates source string at the end of destination string.

C Syntax

char * strcat ( char * destination, const char * source ); 

strncat ( )

  • In C-Programming the strncat() function is used for concatenating ( appending ) portion of one string at the end of another string.

C Syntax

char * strncat ( char * destination, const char * source, size_t num ); 

strcpy ( )

  • In C-Programming the strcpy() function is used for copying contents of one string into another string.

C Syntax

char * strcpy ( char * destination, const char * source );

strncpy ( )

  • In C-Programming the strncpy() function is used for copying the portion of contents of one string into another string.

C Syntax

char * strncpy ( char * destination, const char * source, size_t num );

strlen ( )

  • In C-Programming the strlen() function is used for finding the length of the string.

C Syntax

size_t strlen ( const char * str );

strcmp ( )

  • In C-Programming the strcmp( ) function is used for comparing two given strings and returns zero if they are same..

C Syntax

int strcmp ( const char * str1, const char * str2 );

strcmpi ( )

  • In C-Programming the strcmpi( ) function is used for comparing two given strings.
  • But, strcmpi( ) function is not case sensitive. i.e, “A” and “a” are treated as same characters.

C Syntax

int strcmpi ( const char * str1, const char * str2 );

strchr ( )

  • In C-Programming the strchr( ) function is used for defining the returns pointer to the first occurrence of the character in a given string.

C Syntax

char *strchr(const char *str, int character);

strstr ( )

  • In C-Programming the strstr( )function is used for return pointer to the first occurrence of the string in a given string.

C Syntax

char *strstr(const char *str1, const char *str2);

strrstr ( )

  • In C-Programming the strrstr( )function is used for return pointer to the last occurrence of the string in a given string.

C Syntax

char *strrstr(const char *str1, const char *str2);

strdup ( )

  • In C-Programming the strdup( )function is used for creating a duplicated string.

C Syntax

char *strdup(const char *string);*str2);

strlwr ( )

  • In C-Programming the strlwr( )function is used for converting the given string into lowercase.

C Syntax

char *strlwr(char *string);

strupr ( )

  • In c-Programming the strupr( )function is used for converting the given string into Uppercase

C Syntax

char *strupr(char *string);

strrev ( )

  • In C-Programming the strrev( )function is used for converting the given string into reverse order.

C Syntax

char *strrev(char *string);

strset ( )

  • In C-Programming the strset( )function is used for setting all the characters in a string to given character.

C Syntax

char *strset(char *string, int c);

strnset ( )

  • In C-Programming the strset( )function is used for setting the portion of characters in a string to given character.

C Syntax

char *strnset(char *string, int c);

strtok ( )

  • In C-Programming the strset( )function is used for tokenizes/parses the given string using delimiter.

C Syntax

char * strtok ( char * str, const char * delimiters );

View More Quick Examples


Related Searches to C-String Functions