GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Tech FAQs  >  Programming  >  C
Go To First  |  Previous Question  |  Next Question 
 C  |  Question 101 of 110    Print  
String Concatination
How to concatenate the two string without using the predefined functions (such as strcat and strlen)?


  
Total Answers and Comments: 3 Last Update: July 02, 2009     Asked by: Tarkeshwar_Prasad 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
April 13, 2009 22:37:41   #1  
kakiharanadh Member Since: April 2009   Contribution: 2    

RE: String Concatination
char* strcat(char *s char*t)
{
if( t NULL)
return s;

char *temp s;
while( *s ! ' ') // don't compare like *s++! ' ' it lead to errors since wrong pointing.
s++;
while( (*s++ *t++)! ' ');
return temp;
}

 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    
July 02, 2009 01:47:26   #2  
vbablu Member Since: February 2009   Contribution: 4    

RE: String Concatination
void main() { char s1[40] s2[20]; int i 0 j 0;
printf("enter a string");
scanf(" s" s1);
printf("enter another string");
scanf(" s" s2);
while(s1[i]! ' ')
i++;
while(s2[j]! ' ')
s1[i++] s2[j++];
s1[i] ' ';
printf("concatenated string is s" s1);
}

 
Is this answer useful? Yes | No
July 02, 2009 01:59:18   #3  
vbablu Member Since: February 2009   Contribution: 4    

RE: String Concatination
void main() { char s[20]; int i n;
printf( enter a string );
scanf( s s);
for(i 0;s[i]! '';i++)
{
if(s[i] '.')
{
s[i] '';
break;
}}
n atoi(s);
if(n<255)
printf( d is less );
else
printf( not less );
}

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape