Showing posts with label string copy without library function. Show all posts
Showing posts with label string copy without library function. Show all posts

Wednesday, November 25, 2015

Copy String Without Using Library Function

#include<stdio.h>
#include<conio.h>
void STRCOPY(char[],char[]);
int main()
{
     char str1[100], str2[100];
     clrscr();
     printf("Enter String to Copy: \n");
     gets(str1);
     STRCOPY(str1,str2);
     printf("Copied Sentence : %s", str2);
     getch();
     return 0;
}

void STRCOPY(char str1[],char str2[])
{
     int i=0;
     if(str1 != "")
     {
  while(str1[i] != '\0')
  {
     str2[i] = str1[i];
     i++;
  }
     }
     str2[i] = '\0';
}

To Compile Press Alt+f9 
To Run Press Ctrl+f9

Output: