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

main() { int i=-1; -i; printf("i = %d, -i = %d \n",i,-i); }

1 Answers  


#include <stdio.h> main() { char * str = "hello"; char * ptr = str; char least = 127; while (*ptr++) least = (*ptr<least ) ?*ptr :least; printf("%d",least); }

1 Answers  


main() { int i=5,j=6,z; printf("%d",i+++j); }

2 Answers  


Given a list of numbers ( fixed list) Now given any other list, how can you efficiently find out if there is any element in the second list that is an element of the first list (fixed list)

3 Answers   Disney, Google, ZS Associates,


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

4 Answers   CSC,


Link list in reverse order.

8 Answers   NetApp,


Write a program that reads a dynamic array of 40 integers and displays only even integers

2 Answers  


main() { int i=1; while (i<=5) { printf("%d",i); if (i>2) goto here; i++; } } fun() { here: printf("PP"); }

1 Answers  


int swap(int *a,int *b) { *a=*a+*b;*b=*a-*b;*a=*a-*b; } main() { int x=10,y=20; swap(&x,&y); printf("x= %d y = %d\n",x,y); }

1 Answers  


What is full form of PEPSI

0 Answers  


Given an array of size N in which every number is between 1 and N, determine if there are any duplicates in it. You are allowed to destroy the array if you like.

21 Answers   ABC, eBay, Goldman Sachs, Google, HUP, Microsoft, TATA,


what is brs test reply me email me kashifabbas514@gmail.com

0 Answers  


Categories