ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Code Snippets  >>  Programming Code  >>  C Code
 
 


 

 
 C Code interview questions  C Code Interview Questions
 C++ Code interview questions  C++ Code Interview Questions
 VC++ Code interview questions  VC++ Code Interview Questions
 Java Code interview questions  Java Code Interview Questions
 Dot Net Code interview questions  Dot Net Code Interview Questions
 Visual Basic Code interview questions  Visual Basic Code Interview Questions
 Programming Code AllOther interview questions  Programming Code AllOther Interview Questions
Question
String copy logic in one line.
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: String copy logic in one line.
Answer
# 1
strpy(n1,n2)
here copy of string n2 in string n1
 
Is This Answer Correct ?    3 Yes 11 No
Vijay
 
  Re: String copy logic in one line.
Answer
# 2
while(str1[i]!=0) str2[j++]=str1[i++];
 
Is This Answer Correct ?    7 Yes 6 No
Raghuram.A
 
 
 
  Re: String copy logic in one line.
Answer
# 3
for(i=0;(str2[i]=str1[i])!='\0';i++);
 
Is This Answer Correct ?    7 Yes 2 No
Lavanya
 
  Re: String copy logic in one line.
Answer
# 4
while ((*target++ = *source++));
 
Is This Answer Correct ?    12 Yes 2 No
Yash
 
  Re: String copy logic in one line.
Answer
# 5
for(i=0; str2[i] = str1[i]; i++);
 
Is This Answer Correct ?    4 Yes 5 No
Shruthirap
 
  Re: String copy logic in one line.
Answer
# 6
strcpy(s1,s2); //copies string s1 to s2
 
Is This Answer Correct ?    1 Yes 8 No
Rajendra
 
  Re: String copy logic in one line.
Answer
# 7
void cpy_user(char *s, char *t)
{
while ((*s++ = *t++) != '\0');
}
 
Is This Answer Correct ?    3 Yes 3 No
Jitendra
 
  Re: String copy logic in one line.
Answer
# 8
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 ?    2 Yes 4 No
Anurag
 
  Re: String copy logic in one line.
Answer
# 9
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 ?    2 Yes 3 No
Anurag
 

 
 
 
Other C Code Interview Questions
 
  Question Asked @ Answers
 
Given n nodes. Find the number of different structural binary trees that can be formed using the nodes. Aricent7
Give a very good method to count the number of ones in a 32 bit number. (caution: looping through testing each bit is not a solution) Microsoft5
Program to find the largest sum of contiguous integers in the array. O(n)  7
void main() { int i; char a[]="\0"; if(printf("%s\n",a)) printf("Ok here \n"); else printf("Forget it\n"); }  1
String reverse with time complexity of n/2 with out using temporary variable. NetApp8
main() { int c[ ]={2.8,3.4,4,6.7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf(" %d ",*c); ++q; } for(j=0;j<5;j++){ printf(" %d ",*p); ++p; } }  1
How to return multiple values from a function?  4
main() { extern int i; i=20; printf("%d",i); }  1
main() { int i=10; i=!i>14; Printf ("i=%d",i); }  1
Write out a function that prints out all the permutations of a string. For example, abc would give you abc, acb, bac, bca, cab, cba. You can assume that all the characters will be unique. Microsoft4
#if something == 0 int some=0; #endif main() { int thing = 0; printf("%d %d\n", some ,thing); }  1
main( ) { char *q; int j; for (j=0; j<3; j++) scanf(“%s” ,(q+j)); for (j=0; j<3; j++) printf(“%c” ,*(q+j)); for (j=0; j<3; j++) printf(“%s” ,(q+j)); }  1
main() { char not; not=!2; printf("%d",not); }  1
Link list in reverse order. NetApp7
main() { char *p; p="Hello"; printf("%c\n",*&*p); }  1
main(){ char a[100]; a[0]='a';a[1]]='b';a[2]='c';a[4]='d'; abc(a); } abc(char a[]){ a++; printf("%c",*a); a++; printf("%c",*a); }  1
main() { char s[ ]="man"; int i; for(i=0;s[ i ];i++) printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]); }  1
union u { struct st { int i : 4; int j : 4; int k : 4; int l; }st; int i; }u; main() { u.i = 100; printf("%d, %d, %d",u.i, u.st.i, u.st.l); } a. 4, 4, 0 b. 0, 0, 0 c. 100, 4, 0 d. 40, 4, 0 HCL1
main() { show(); } void show() { printf("I'm the greatest"); }  1
#include <stdio.h> main() { char * str = "hello"; char * ptr = str; char least = 127; while (*ptr++) least = (*ptr<least ) ?*ptr :least; printf("%d",least); }  1
 
For more C Code Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com