...

/

Example 74: Common String Functions Implementation

Example 74: Common String Functions Implementation

Learn how to implement common string functions.

Problem

Write a program to implement the following functions:

  1. strlen: Finds the length of the string
  2. strcpy: Copies contents of one string to another string
  3. strcat: Appends one string at the end of another string
  4. strcmp: Compares two strings to find whether they are identical or not

Example

Suppose we have the following four strings:

  • s1[] = “kicit”
  • s2[] = “Nagpur”
  • s3[20] = “”
  • s4[] = “kicit”

These strings will be used as inputs for the examples given in the table below.

Function Input Output
strLen s1 5
strCpy s3, s1
...
Access this course and 1400+ top-rated courses and projects.