Hello. In this episode, we will see a new type : "string". This type will let us declare variables containing character strings. A character string is simply a list of characters, such as a word, a sentence. For example, "Hello everybody!". In order to use this new type, we must include its definition. This means we will will have to add this this line at the beginning of the program : #include <string> Then, we can declare string-type variables. We will do it like this : As usual, we will start with the type of the variable, here "string" followed by the name we wish to give to the variable. We will finish by a semicolon. In this example of code, we start by indicating the line " #include <string> " so that we can use this new "string" type. In this line, we are declaring a variable called "un_nom" (TN: means "a_name"). For now, it is initialized to the empty character string. This is a specificity of the "string" type in comparison with the already encountered types. If we do not put any explicit initial value, the value is initialized to the empty string. However, this second declaration declares a variable "message" initialized to "Bonjour à tous !" (TN: means "Hello everyone!") Be careful though, these characters called "quotation marks" or "double quotes" are not part of the string. They are merely used to indicate the beginning and the end of the string. Character strings are thus constituted of characters. These characters have their own type called "char". Thus, we can declare variables containing only one character. For example, here, we are declaring a variable called c containing the character " x ". We can represent it like this. Please note that the character x is between apostrophes also called "simple quotes". On the other hand, character strings are delimited by quotation marks or double quotes. In this second declaration, we are declaring a variable u also of the type char. It is not initialized; this means we do not know what it contains. Once we execute this instruction, which is an assignment, we will assign the character 's' to the variable u. Please endeavor not to mix the types "char" and "string". For example, if we write " char s('c'); " , it is the declaration of a variable which will perforce contain a single character since "char" is its type. If we write : " string s("c"); " it is the declaration of a character string which will contain one character. Thus, be careful as you cannot write, for example, " char s("c"); " since this is of the type "string". We cannot assign a string-type value to our char-type variable s. A good mnemonic way to remember this is that a char-type variable can only contain one character, we thus use simple quotes. A character string will generally contain more than one character, and we will thus double quotes to delimit a character string. As for any other type, we can modify, through an assignment, variables declared of the type "string". For example, let us start by declaring a string-type variable called "chaine". (TN: means "string") We are not giving any value to initialize it. Remember that, in this case, "chaine" will be initialized to the empty string. Then, here, we declare a second variable, still of the type "string" and call it "chaine2". "chaine2" is initialized to the "test" string. Then, here, we do an assignment changing the value of "chaine". we will put "test3" into "chaine". In the following assignment, we are copying the value of "chaine2" into "chaine". Therefore, "chaine 2" will contain "test". This "test3" here will be replaced by the character string "test". In this last assignment, we are assigning the character 'a' to the variable "chaine", that is, this one. Here, it is indeed a character since we are using simple quotes, apostrophes to delimit the characters. However, C++ will automatically convert this char-type value into a string-type value, that is, a character string we can represent like this. Now, after this last assignment, "chaine" contains the string "a". Also, we can concatenate two strings. This means we can put two strings one after other thanks to the " + " operator. For example, if we have "chaine1" and "chaine2", two string-type variables, we can write this. This will result in a new character string beginning with the characters of "chaine1" and ending with the characters of "chaine2". For example, in this code, we are declaring three string-type variables. For now, they are all initialized to the empty character string. Let us suppose we have given a value to the variable "prenom" (TN: means "first name"), for example, "Jean" and a surname in the variable "famille". (TN: means "family"). Once we execute this assignment, we will first concatenate the value of the variable "famille" with this character string which simply contains a blank space. This will give us "Dupont" followed by a blank space. Let us represent it like this. Then, we will add the content of the variable "prenom", that is, "Jean". All this forms a new character string which we will store in the variable "nom" upon the assignment. The following combinations are possible for the concatenation of two strings. We can concatenate two string-type variables. We can also concatenate a string-type variable with a literate value of the type "string". Or, we can start with the literal value followed by the string-type variable. We can also start with a string-type variable and add a character. We can also begin with the character and concatenate it with a string-type variable. Let us go back to the example of the previous slide. We had used a string-type literal value to represent the blank space we wished to inserate between the first name and the surname. Actually, we may also use a character. We are doing just that here, using simple quotes. This thing here is a char-type literal value. We may very well concatenate a "char" with a string-type variable. You can see this here. Concatenations of the form string + char are very practical to add characters at the end of a character string. For example, here, we declare a variable "reponse". (TN: means "answer") It contains the character string "solution". When a variable " n " is greater than 1, we would like to put "solution" in the plural. To that end, we will use this assignment. For now, the variable "reponse" contains "solution". And we will simply concatenate it with the character 's'. We will thus obtain the string "solutions" with an " s " at the end. We will then store the result in our variable "reponse". Now, "reponse" will therefore contain "solutions", in the plural. We can use the same trick to add characters at the beginning of a string. As for other types, we will use the " == " symbol to test if two strings are equal. Also, we will use the " != " symbol to test if two strings are different. For example, in this code, we are using a "do while loop". Inside, we are calling a function which asks a question. The result of this function is a character string which we will assign to our variable "reponse". We wish to keep asking the question as long as the answer is not "oui" (TN: means "yes" ) To that end, we will write, between the parentheses, this condition here. It will test if "reponse" is different from the character string "oui". This should be enough for this introduction on the character strings. In the following episode, we will discuss manipulations on strings.