By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,826 Members | 2,384 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,826 IT Pros & Developers. It's quick & easy.

Code for Concatenation and substr

P: 3
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
Share this Question
Share on Google+
3 Replies

P: 3
Please reply it as early as possible if anybody knows it
Sep 21 '06 #2

P: 61
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

P: 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 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.