Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c

Pre-defined string function example C Programming language

Posted on September 2, 2017January 24, 2020

Table of Contents

  • Pre-defined string function in C Programming language
    • Related

Pre-defined string function in C Programming language

In this tutorial, we will discuss the pre-defined string function in the C Programming language.


The c programming language has inbuilt string functions which are declared in string.h header file. This functions can be used in many string operations in C language.

1. strlen() – The String function can be used to calculate the length of String

Syntex

strlen(string_name) ;
Pre-define string function
Example

Output

20

2. strupr() – this function converts the given string into uppercase

Syntex

strupr(string_name) ;
Pre-define string function
Example

Output

MY NAME IS MR KANNAN

3. strlwr () -this function converts the given string into lowercase

Syntex

strlwr(string_name) ;
Pre-define string function
Example

3. strset() – this function sets all characters in string to ch

Syntex

strset(string_name,'ch') ;

 

Pre-define string function
Example

Output

**************

4. strnset()-this function helps to set the first given numbers of  character in string to ch

Syntex

strnset(string_name,'ch',count) ;

 

Pre-define string function
Example

Output

******s string function

5. strrev()- This function reverses all character in given String

Syntex

strrev(string_name) ;

 

 

Pre-define string function
Example
Output
 noitcnuf gnirts si siht
6. strspn()-this function gives the number of character in the initial segment of first_string_name, which has the same characters from second_string_name

Syntex

strspn(first_string_name,second_string_name) ;
Pre-define string function
Example

Output
8

7. strcmp()-this function compares two strings and gives an integer value

when string 1 was  equal to string 2, return value 0
when string 1 was less than string 2, return value is a negative integer;
when string 1 was greater than string 2, the return value is a negative integer;

Syntex

strcmp(first_string_name,second_string_name) ;

Output
-1

8. stricmp()-this function compares two strings and the given integer value but not it is not case sensitive

when string 1 was  equal to string 2, returns value is 0
when string 1 was less than string 2, returns value is a negative integer;
when string 1 was greater than string 2, returns value is a negative integer;

Syntex

stricmp(first_string_name,second_string_name) ;

Output
0

9. strcpy()-this function copies the content of one string into another string 


Syntex

strcpy(first_string_name,second_string_name) ;

Output

this is function

10. strncpy

this function copies the given number of character of one string to another

Syntex

strcmp(first_string_name,second_string_name,count) ;

 

Output

learn

11. strstr()-This function returns the pointer to first occurrence of first_string in second_string

Syntex

strstr(first_string_name,second_string_name) ;

Output

c language

12. strcat()- concatenates second_string at the end of the first_string


Syntex

strcat(first_string_name,second_string_name) ;

Output

learning c language

13. strncat()- concatenates given number of character of second_string at the end of the first_string

Syntex

strstr(first_string_name,second_string_name,count) ;

Output

learning java and c

14.strchr-

The strrchr() function is used to returns a pointer to the first occurance of the given string

Syntax

char* strrchr (const char *str,int c)

15. strrchr()-

The strrchr() function is used to returns a pointer to the last occurance of the given string

Syntax

char* strrchr (char* str,int ch)

Output
language

16. strdup()-

The strdup() function is used to duplicate the given string

Stntax

char*strdup(const char*s)

Output
learning c language

17. strrev()-

The strrev() function is used to reverse the given string

Syntax

char*strrev(char *str)

 

Pre-define string function
Example

 

Suggested for you

Function in C language

String function in C language

String function in Python language

Arithmetic function in Python language

 

Related

Recent Posts

  • Multiply two numbers in Java using scanner| 5 different ways
  • 5 different ways to Divide two numbers in Java using scanner
  • Learn 8 Ways to Subtract Two Numbers Using Methods in Java
  • 10 ways to subtract two numbers in Java
  • Java Code Examples – Multiply Two Numbers in 5 Easy Ways
  • How to Divide two numbers in Java| 5 different ways

tag

Addition (8) Array (38) C++ language (91) C language (98) c sharp (23) Division (8) Function (29) if else (32) Java language (108) JavaScript (5) loops (138) Multiply (8) Oop (2) patterns (66) PHP (13) Python Language (38) Subtraction (9) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2026 Code for Java c | Powered by SuperbThemes