C Programming for Beginners : String Functions

Suraj Das
3 min readNov 19, 2021

Time to perform some operations on strings 😃

Make sure to include the string.h file on the top.

Compute String Length

The strlen() function calculates the length of a given string.

Length of name is : 7

Note that the data type of variable l is int (to measure the length).

Convert a String to Lowercase

The strlwr() function converts the string to lowercase.

BTS turned to bts

Convert a String to Uppercase

The strupr() function converts the string to uppercase.

ANIME is my besto frendo!

Copy a String to another

Function : strcpy()

Tom Holland and Tom Hiddleston

Concatenate (Join) Strings

In C programming, the strcat() function concatenates (joins) two strings.

Programatrix will always be there for you :)

Compare Two Strings

The strcmp() compares two strings character by character.

If the strings are equal, the function returns 0.

The possible values of strcmp() are 0, 1 and -1.

0
1
-1

It returns 1 when the first non-matching character in str1 is greater (in ASCII) than that of str2.

And it returns -1 when the first non-matching character in str1 is lower (in ASCII) than that of str2.

Reverse a String

Function : strrev()

I am sad :(

Hope you enjoyed this blog.

Jeez! That was worth exploring 😃

Have any doubt ?
DM me on Instagram

Peace ✌️

Index of C Programming lessons :

  1. Getting Started within 5 minutes
  2. Learning Fundamentals Made Easy
  3. Circumference and Area of Circle
  4. scanf() vs fgets()
  5. Hypotenuse Calculator
  6. Learn by Building a Calculator
  7. Functions
  8. More on Functions
  9. Length of an Array
  10. String Functions
  11. The While Loop

--

--