C Program to Manipulate String without Use of Manipulation Functions

#include <stdio.h>
#include <conio.h>
void main()
{
    char str[30]="Deepraj",copy[30],rev[30];
    int i,j;
    printf("The string is %s",str);

    /*C Program to Find the Length of String without strlen() */
    for(i=0;str[i]!='\0';i++);  /* i contains the length of string */
  printf("\nLength of the string is %d",i);

    /*C Program to Copy String without strcpy() */
    for(i=0;str[i]!='\0';i++)
    {
        copy[i]=str[i];
    }
    copy[i]='\0';
    printf("\nCopy of the string is %s",copy);

    /*C Program to Reverse the String without strrev() */
    for(i=0;str[i]!='\0';i++); /* i contains the length of string */
    i--;
    for(j=0;i>=0;j++,i--)
    {
        rev[j]=str[i];
    }
    rev[j]='\0';
    printf("\nReverse of the string is %s",rev);

    /*C Program to Concatenate the Strings without strcat() */
    for(i=0;str[i]!='\0';i++); /* i contains the length of string */
    char join[]="Bhujel";
    for(j=0;join[j]!='\0';j++,i++)
    {
        str[i]=join[j];
    }
    str[i]='\0';
    printf("\nConcatenation of the strings is %s",str);
    getch();
}

OUTPUT:

No comments:

Post a Comment