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

plz send me all data structure related programs

2 Answers  


writte a c-programm to display smill paces

2 Answers  


respected sir, i did my MCA in 2013 when i am going to attend to an interview i was asked about my project how will i explain my project could please help me in this and my project title is "Social Networking Site For Social Responsibility"

1 Answers   Genpact, Ozdocs,


A program that will create a movie seat reservation. The program will display the summary seats and its status. The user will be ask what seat no. to be reserved, then it will go back again to the summary to display the updated seat status. If the seat no. is already reserved then it will prompt an error message. And also if the input seat no is out of range then it will also prompt an error message. The program is continuously running. Termination of the program will depends on how the programmer will apply. Sample output: Movie Seats Reservation Summary of Seats: Seat 1: Available Seat 2: Available Seat 3: Available Seat 4: Available Seat 5: Available Enter seat no. (Press 0 to terminate Or the assigned seat capacity) : 1 Movie Seats Reservation Summary of Seats: Seat 1: Reserve Seat 2: Available Seat 3: Available Seat 4: Available Seat 5: Available Enter seat no. (Press 0 to terminate Or the assigned seat capacity) : 6 The Seat no. is out of range! Movie Seats Reservation Summary of Seats: Seat 1: Reserve Seat 2: Available Seat 3: Available Seat 4: Available Seat 5: Available Enter seat no. (Press 0 to terminate Or the assigned seat capacity) : 1 The Seat no. is already reserved! Movie Seats Reservation Summary of Seats: Seat 1: Reserve Seat 2: Available Seat 3: Available Seat 4: Available Seat 5: Available Enter seat no. (Press 0 to terminate Or the assigned seat capacity) : 0 GoodBye... Thank You!!!

0 Answers  


main() { { unsigned int bit=256; printf("%d", bit); } { unsigned int bit=512; printf("%d", bit); } } a. 256, 256 b. 512, 512 c. 256, 512 d. Compile error

1 Answers   HCL,






write a program to count the number the same (letter/character foreg: 's') in a given sentence.

2 Answers  


#include<stdio.h> main() { int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} }; int *p,*q; p=&a[2][2][2]; *q=***a; printf("%d----%d",*p,*q); }

1 Answers  


Code for 1>"ascii to string" 2>"string to ascii"

1 Answers   Aricent, Global Logic,


write a program for area of circumference of shapes

0 Answers  


Extend the sutherland-hodgman clipping algorithm to clip three-dimensional planes against a regular paralleiepiped

1 Answers   IBM,


Given a spherical surface, write bump-mapping procedure to generate the bumpy surface of an orange

0 Answers  


How will you print % character? a. printf(“\%”) b. printf(“\\%”) c. printf(“%%”) d. printf(“\%%”)

4 Answers   HCL,


Categories