468,484 Members | 1,761 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,484 developers. It's quick & easy.

Code for Concatenation and substr

hi freinds,
I want the code for string concatenation and string substr without using the strcat and substr functions...
What could be C++ code for this?
Sep 21 '06 #1
3 3984
Please reply it as early as possible if anybody knows it
Sep 21 '06 #2
Why don't you give a try??


your should be same as the prototype of strcat()

char *xstrcat(char *str1, char *str2)

move the pointer forward unless it points to a null character, i.e., access all the elements of the first string by the pointer str1. Then acceess each element of second string to the first. At last add a null character.

Provide the prototype for the function substr().
Sep 21 '06 #3
void concat()
char str1[29];
char str2[29];
char str3[29];
cout<<"Enter string1;
cin>> str1[p];
cout<<"Enter string2;
cin>> str2[q];
for(int i=0,j=0;str1[i]!='\0';i++,j++)

for(int k=0;str2[k]!='\0';k++,i++)

This is waht i tried for concatenation..but its not working..there is some error when i am taking the input into the strings str1 and str2...i am not able to read the input properly into the strings..how to read the input properly>???
Sep 21 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by MuffinMan | last post: by
3 posts views Thread by Craft | last post: by
5 posts views Thread by Jonas Galvez | last post: by
1 post views Thread by Jim Dawson | last post: by
18 posts views Thread by Larry Menard | last post: by
reply views Thread by Lildog | last post: by
6 posts views Thread by sks | last post: by
5 posts views Thread by jgentes | last post: by
2 posts views Thread by gieforce | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.