#include<stdio.h>
void copystr(char [],char []);
void main()
{
char str1[50],str2[50];
printf("Enter 1st string,str1 : ");
gets(str1);
printf("\nEnter 2nd string,str2 : ");
gets(str2);
copystr(str1,str2);
printf("\n\nAfter copying str2 in str1\n\nstr1 is %s ",str1);
getch();
}
void copystr(char txt1[], char txt2[])
{
int i;
for(i=0;txt2[i]!='\0';i++)
{
txt1[i]=txt2[i];
}
txt1[i]='\0';
}
Monday, July 31, 2017
Home »
C Programming
» Copying string 2 to string 1
Copying string 2 to string 1
Related Posts:
Arranging numbers in ascending and descending order in C#include<stdio.h> void main() { int x[5],i,j,temp; for(i=0;i<=4;i++) { printf("Enter x[%d]th number : ",i); scanf("%d"… Read More
Find triangular no. in C#include<stdio.h> void main() { int n1,n2,i,t; printf("Enter two numbers : "); scanf("%d%d",&n1,&n2); for(i=1;i<=n2;i++) { &… Read More
Find largest and smallest no. in C#include<stdio.h> void main() { int x[10],i,j,temp; for(i=0;i<=9;i++) { printf("Enter %dth number : ",i+1); scanf("%d"… Read More
Find highest paid employee in C#include<stdio.h> struct emp { char name[50]; int salary; }; void main() { int n,i,sum=0,avg; struct emp e[20],ls,hs; printf("Enter the number of emp… Read More
Operations on complex numbers in C#include<stdio.h> struct cmplx { float real; float img; }; struct cmplx add(struct cmplx x, struct cmplx y) { struct cmplx z; z.real = x.real + y.real; &nbs… Read More
0 comments:
Post a Comment