Concatenating Strings - a review

As I mentioned, I'm learning/employing a bunch of varied programming languages. In fact, I'm employing several programming languages within a single project. While tabbing betwixt editor windows I'll often miss tabbing between programming languages. Fortunately, error codes are as they are and they yell at me promptly.

To review, concatenating strings:

Javascript


var mystring = string1 + " is " + string2;

Ruby and Python


mystring = string1 + " is " + string2;

PHP


$mystring = $string1." is ".$string2;

C

char mystring[50], string1[10], string2[10];

strcat(mystring, string1);
strcat(mystring, " is ");
strcat(mystring, string2);

C++

string mystring, string1,string2;
mystring = string1 + " is " + string2;

Feel free to add any more you know.

About this article

written on
posted in Programming Back to Top

About the Author

Andrew Turner is an advocate of open standards and open data. He is actively involved in many organizations developing and supporting open standards, including OpenStreetMap, Open Geospatial Consortium, Open Web Foundation, OSGeo, and the World Wide Web Consortium. He co-founded CrisisCommons, a community of volunteers that, in coordination with government agencies and disaster response groups, build technology tools to help people in need during and after a crisis such as an earthquake, tsunami, tornado, hurricane, flood, or wildfire.