String copy logic in one line.

Answers were Sorted based on User's Feedback



String copy logic in one line...

Answer / yash

while ((*target++ = *source++));

Is This Answer Correct ?    41 Yes 9 No

String copy logic in one line...

Answer / lavanya

for(i=0;(str2[i]=str1[i])!='\0';i++);

Is This Answer Correct ?    20 Yes 5 No

String copy logic in one line...

Answer / raghuram.a

while(str1[i]!=0) str2[j++]=str1[i++];

Is This Answer Correct ?    17 Yes 14 No

String copy logic in one line...

Answer / marrthand

for(i=0;i<=strlen(s1[i];i++){s1[i]=s2[i];}

Is This Answer Correct ?    2 Yes 0 No

String copy logic in one line...

Answer / gowrishankaran

while(str1[i]!=0) str2[j++]=str1[i++];

Is This Answer Correct ?    2 Yes 1 No

String copy logic in one line...

Answer / shruthirap

for(i=0; str2[i] = str1[i]; i++);

Is This Answer Correct ?    9 Yes 9 No

String copy logic in one line...

Answer / jitendra

void cpy_user(char *s, char *t)
{
while ((*s++ = *t++) != '\0');
}

Is This Answer Correct ?    7 Yes 7 No

String copy logic in one line...

Answer / anurag

SORRY !!!
The last posted Ans. is for reverse of the string in one
line...by mistake it has been posted in this.

Is This Answer Correct ?    4 Yes 5 No

String copy logic in one line...

Answer / anurag

int i=0,len=strlen(str);
int j=len/2;len--;
while(i<j)
{
*(str+i)^=*(str+len)^=*(str+i)^=*(str+len);
len--;i++;
}

Is This Answer Correct ?    4 Yes 7 No

String copy logic in one line...

Answer / vijay

strpy(n1,n2)
here copy of string n2 in string n1

Is This Answer Correct ?    12 Yes 24 No

Post New Answer

More C Code Interview Questions

Write a program to check whether the number is prime and also check if it there i n fibonacci series, then return true otherwise return false

1 Answers   Cognizant, lenovo,


#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }

2 Answers  


How can I Create a C program in splitting set of characters to specific subsets. Example: INPUT SET OF CHARACTERS: Therefore, my dear brothers and sisters, stand firm. Let nothing move you. Always give yourselves fully to the work of the Lord, because you know that your labor in the Lord is not in vain. SPLIT INTO HOW MANY CHARACTERS PER SUBSETS: 10 OUTPUT: Therefore, my dear b rothers an d sisters, stand fir m. Let not hing move you. Alway s give you rselves fu lly to the work of t he Lord, b ecause you know that your labo r in the L ord is not in vain.

0 Answers  


void main() { static int i; while(i<=10) (i>2)?i++:i--; printf(ā€œ%dā€, i); }

2 Answers  


Write a program that produces these three columns sequence nos. using loop statement Sequence nos. Squared Squared + 5 1 1 6 2 4 9 3 9 14 4 16 21 5 25 30

1 Answers   GoDB,






main() { int i=3; switch(i) { default:printf("zero"); case 1: printf("one"); break; case 2:printf("two"); break; case 3: printf("three"); break; } }

1 Answers  


write a program to Insert in a sorted list

4 Answers   Microsoft,


void main() { void *v; int integer=2; int *i=&integer; v=i; printf("%d",(int*)*v); }

1 Answers   Honeywell,


Write a program to model an exploding firecracker in the xy plane using a particle system

0 Answers   HCL,


main() { int i=5; printf(ā€œ%dā€,i=++i ==6); }

1 Answers  


main() { int i=300; char *ptr = &i; *++ptr=2; printf("%d",i); }

4 Answers   CSC,


Is the following statement a declaration/definition. Find what does it mean? int (*x)[10];

1 Answers  


Categories