All articles
c

A program to explain string manipulations - Part 2

Share this article

Share on LinkedIn Share on X (formerly Twitter)

C Programming Language 072

  • Write a program to use following string handling functions
    1. strlwr()
    2. strupr()
    3. strrev()
    4. strcpy()

Program

#include <stdio.h>
#include <string.h>
 
void main()
{
    char str1[30], str2[30];
 
    printf("Enter string1: ");
    gets(str1);
 
    strcpy(str2, str1);
    printf("String 2 = %s \n", str2);
 
    strrev(str1);
    printf("Reverse = %s \n", str1);
 
    strlwr(str2);
    printf("Lowercase = %s \n", str2);
 
    strupr(str2);
    printf("Uppercase = %s \n", str2);
 
    printf("\n");
}

Result

Functions such as like strupr, strlwr, strrev, which are only available in ANSI C (Turbo C/C++) and are not available in standard C-GCC compiler.

Comments