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

What are segment and offset addresses?

2 Answers   Infosys,


main() { printf("%d", out); } int out=100;

3 Answers  


Program to find the largest sum of contiguous integers in the array. O(n)

11 Answers  


#define DIM( array, type) sizeof(array)/sizeof(type) main() { int arr[10]; printf(“The dimension of the array is %d”, DIM(arr, int)); }

1 Answers  


main() { unsigned int i=10; while(i-->=0) printf("%u ",i); }

2 Answers   HP,


how to return a multiple value from a function?

5 Answers   Wipro,


Write a procedure to implement highlight as a blinking operation

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,


print a semicolon using Cprogram without using a semicolon any where in the C code in ur program!!

35 Answers   Tata Elxsi, TCS, VI eTrans,


Is the following code legal? typedef struct a { int x; aType *b; }aType

1 Answers  


how many processes will gate created execution of -------- fork(); fork(); fork(); -------- Please Explain... Thanks in advance..!

8 Answers   GATE,


Derive expression for converting RGB color parameters to HSV values

1 Answers  


Categories