+ 3

Use for Concatenation

Will you please explain to me the use for concatenation? I’m not understanding the use for it.

28th Nov 2019, 7:12 PM
Kyree
Kyree - avatar
18 Answers
+ 5
Kyree concatenating a string is very common pratice in programming. Now I'm coming to your question, what's the use of a concatenation of string in programming. Here is one example that may explain you about concatenation. firstName = "John"; lastName = "smith"; print("Hello " + firstName + " " + lastName); //Output //Hello John smith As you can see variable firstName and Variable lastName storing a value that is assigned to each one of them respectively. Now you can use this variable istead of typing the name of the person. whenever you want to change the person name just change the value of that particular variable. I hope that you've understand the use of concatenation. Have a good day friend🙃
29th Nov 2019, 6:44 PM
Raj Ghosh
Raj Ghosh - avatar
+ 4
Good+morning=goodmorning String Contacting.
28th Nov 2019, 7:19 PM
Anna/Аня
Anna/Аня - avatar
+ 3
Each day, when a file comes in, I can pick it up and rename it using string concatenation, and put it in the correct directory. If they change the location of the landing directory, I only have to change one variable, and all of the code should still work. String concatenation can save me LOTS of work.
29th Nov 2019, 1:38 AM
JoeSponge
JoeSponge - avatar
+ 3
Kyree , it seems like a lot. You will see that there is method to the path, and reasons for learning things that seem incidental now. Learning the little things is part of mastering the larger skill.
29th Nov 2019, 2:23 AM
JoeSponge
JoeSponge - avatar
+ 3
In real programming world for displaying FIRSTNAME + LASTNAME on User Dashboard,you can use it as illustrated below: FIRSTNAME = "MyFirstName" LASTNAME = "MyLastName" We required full name on User Dashboard after successfully login like, Hello MyFirstName MyLastName..
29th Nov 2019, 9:50 AM
Hardik Prajapati
Hardik Prajapati - avatar
+ 3
strcat("How", "are you") output: How are you IN CPP print("I am" + "fine") ; output: I am fine In PYTHON
30th Nov 2019, 5:28 PM
Aditya
Aditya - avatar
+ 2
You may never use it. But just know that such method exits which can add two strings.
28th Nov 2019, 7:38 PM
Avinesh
Avinesh - avatar
+ 2
Concatenation is important for adding to strings. It is used in many scripts and programs. For example, you made a program for adding to numbers inside a variable. Then you print your answer on the screen. But that does not look good. If you variable is x, you can print "The sum is " + x. It will look more better, better than just showing a number
29th Nov 2019, 6:27 AM
Ahnaf
Ahnaf - avatar
+ 2
It is for joining the word like hello+friends=hellofriends So that's the use
29th Nov 2019, 4:39 PM
Thé Ka|yan M!shrā
Thé Ka|yan M!shrā - avatar
+ 1
Concatenation is generally used for manipulating string data by combining multiple strings.
28th Nov 2019, 7:24 PM
Avinesh
Avinesh - avatar
+ 1
In the long run, concatenation can save your a LOT of work. I work with data. Lots of data. Say I get about 100 files a day. Each data file has a naming pattern. I have seven different data systems, five common data domains for each. I can hard code those over 100 names, or I can break them down into those patterns, and then use string concatenation to handle that for me. So, if I have seven data systems, datsys (SIPS, CORS, TRAIN, REAC, TCS_AB, TFM, RES), ... Then five types, dattype (BIAC, SPC, SIM, TIP, HIST), ... And, figure that they come in daily, and have to move through three areas, dland (LANDING), dstage (STAGE), dout (OUT)... If the files stick to the defined naming pattern, I can build out expected file names, add a date component, and define where they belong on the system. The way as I do that is by using string concat. filename = datsys + dattype + date.strfmt(%Y%M%D) + ".dat" inpath = dland + "/" + filename
29th Nov 2019, 1:30 AM
JoeSponge
JoeSponge - avatar
+ 1
Concatenation is simply joining multiple strings
29th Nov 2019, 10:11 AM
Helix
+ 1
Raj Yes I kind of have a better understanding for concatenation. I’m sure for me to understand the full concept of concatenating strings I will need to learn more about coding and the different situations I will need to use concatenation for. Thanks for the response amigos.
30th Nov 2019, 4:28 AM
Kyree
Kyree - avatar
0
I’m sorry that doesnt exactly answer my question. I understand how to concatenate strings but I want to know when will I need to concatenate strings while writing code?
28th Nov 2019, 7:23 PM
Kyree
Kyree - avatar
0
Ok, well that relieves anxiety. thanks Anna. Thanks Avinesh
28th Nov 2019, 7:44 PM
Kyree
Kyree - avatar
0
JoeSponge Ok, so it depends on what I need to do.. What you said kind of makes sense but that only means I have a lot to learn. Thanks for that.
29th Nov 2019, 1:50 AM
Kyree
Kyree - avatar
0
JoeSponge your’re right. Thanks for the wisdom.
29th Nov 2019, 2:40 AM
Kyree
Kyree - avatar
0
To join word together
31st Oct 2024, 9:22 PM
Mustapha Adedayo
Mustapha Adedayo - avatar