Single Program Using All Automatic String Functions

#include <stdio.h>
#include <string.h>
int main() 

{
    char str1[50], str2[50], copy[50];

    //  1. Reading
    printf("Enter first string: ");
    scanf("%s", str1);

    printf("Enter second string: ");
    scanf("%s", str2);

    //  2. Writing
    printf("\nFirst String: %s", str1);
    printf("\nSecond String: %s", str2);

    //  3. Length
    printf("\nLength of first string: %d", strlen(str1));

    //  4. Copy
    strcpy(copy, str1);
    printf("\nCopied string: %s", copy);

    //  5. Comparison
    if(strcmp(str1, str2) == 0)
        printf("\nStrings are Equal");
    else
        printf("\nStrings are Not Equal");

    //  6. Concatenation
    strcat(str1, str2);
    printf("\nAfter Concatenation: %s", str1);

    //  7. Reverse
    printf("\nReversed string: %s", strrev(copy));

    //  8. Case Conversion
    printf("\nUppercase: %s", strupr(copy));
    printf("\nLowercase: %s", strlwr(copy));
}

Comments

Popular posts from this blog

C program for subtraction of two matrices (2D Arrays)

C program for Multiplication of Two matrices