473,378 Members | 1,396 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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 4137
Please reply it as early as possible if anybody knows it
Sep 21 '06 #2
Why don't you give a try??

concatenation............

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];
for(p=0;p<5;p++)
{
cout<<"Enter string1;
cin>> str1[p];
}
for(q=0;q<5;q++)
{
cout<<"Enter string2;
cin>> str2[q];
}
for(int i=0,j=0;str1[i]!='\0';i++,j++)
str3[i++]=str1[j++];

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

}
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

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

Similar topics

5
by: MuffinMan | last post by:
Hi, I'm trying to add up an integer with the result from substr() like $second_int = substr( .... ) + $int; I know the result from substr() is an integer and so is $int but in the end...
3
by: Craft | last post by:
have this code and I'm trying to get it to work. It mostly works, but $serverpop does not seem to work. What it looks to me like this code does is scan http://www.worldofwarcraft.com­/serverstatus/...
5
by: Jonas Galvez | last post by:
Is it true that joining the string elements of a list is faster than concatenating them via the '+' operator? "".join() vs 'a'+'b'+'c' If so, can anyone explain why?
1
by: Jim Dawson | last post by:
I was writing a subroutine to extract fields from lines of text when I ran into an issue. I have reproduced this error on Perl 5.8 on AIX, 5.8 on Linux and 5.6 on Windows. ############### CUT...
18
by: Larry Menard | last post by:
Is it not valid to use concatenation in a WHERE ... LIKE clause? SELECT iam0.g_itemId FROM g2_ItemAttributesMap AS iam0, g2_ItemAttributesMap AS iam1 WHERE iam1.g_parentSequence LIKE...
0
by: Lildog | last post by:
I use this code to generate random names for jewelry products I will eventually sell. I found this code on the web and wondered if someone could give a detailed description of each line of code? I...
6
by: sks | last post by:
Hi, Here is a small program that is wrtten to simply use substr. When the second parameter in substr (length of the string to be extracted) is lesser than 0, the output is the entire string (I'm...
5
by: vamsioracle | last post by:
Hi all, I have a problem with the ult_smtp package. Let me explain how the structure of my code is procedure------------ begin declarations of variables and cursors...
5
by: jgentes | last post by:
I am looking for help creating a factorial like function, except it will take some user-defined array/list and concatenate the values into a user-defined length ... similar to substr, but not exactly...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.