C program – To copy the contents of one string to another string

by Nideesh C on April 18, 2011 · 0 comments

in C Programming




#include<stdio.h>
#include<conio.h>
void stcpy(char str1[50], char str2[50]);
void main()
{
char str1[50], str2[50];
clrscr();
printf(“nnt ENTER A STRING…: “);
gets(str1);
stcpy(str1,str2);
printf(“nt THE COPIED STRING IS…: “);
puts(str2);
getch();
}
void stcpy(char str1[50], char str2[50])
{
int i, len = 0;
while(str1[len]!=’′)
len++;
for(i=0;i<len;i++)
str2[i] = str1[i];
str2[i] = ‘′;
}

Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. C program – Copy the contents of one string to another string using pointer
  2. C program To reverse the given string
  3. C Program to accepts two strings and compare them. Finally it prints whether both are equal, or first string is greater than the second or the first string is less than the second string
  4. C program – Morse code to text conversion and vice-versa.
  5. C Program to accept two strings and concatenate them i.e.The second string is appended to the end of the first string

Leave a Comment

Previous post:

Next post: