Where is it used and what is the importance of the string type?

-2

I'm starting to program, though, I wanted to know more about the value and importance of type string in programming. In general:

  • Some general aspects of type string ?
  • A little bit about its use, where and how are they used?
  • Would you like a more brief definition to explain what a string is? In a nutshell for someone more lay.
asked by anonymous 24.08.2017 / 19:56

1 answer

6

Short answer

  

Will you write something (texts, phrases, words, characters) to your user?

If you answered yes, then you should know that this is a string , because a string is a sequence of zero or more characters. It is commonly used to represent text or a sequence of bytes.

Response not so short

A "string" or string in is a string of characters, usually used to represent words, phrases, or texts in a program.

In most programming languages, strings can be expressed either in literal form or through some kind of variable. When expressed through variables, the content of the string can usually be changed by adding / deleting elements or by replacing its elements with other elements, forming a new string .

Basically it is as a data type and is usually implemented through a bytes arrangement that stores string elements in sequence using some pre-set encoding.

Text taken from the tag wiki .

Since you did not bookmark a programming language, I'll give examples in PHP :

  

The simplest way to specify a string is to enclose it in single quotation marks (the 'character').

A literal string can be specified in four different ways:

  • single quotes
  • Double quotes
  • syntax heredoc
  • syntax nowdoc (since PHP 5.3.0)

Simple Quotes

echo 'isto é uma string comum';
echo ''; //isso é uma string vazia

Double quotes

echo "isto também é uma string comum";

You can use concatenated variables too:

$nome = "Ygo";
echo "isto é uma string concatenada com uma variável".$nome; //imprime isto é uma string concatenada com uma variável Ygo

You can also store text in a variable:

$texto = "isto é uma string dentro de uma variável";
echo $texto; //imprime isto é uma string dentro de uma variável

Sometimes, in foreign words it is necessary to escape through the counter bar ( \ ):

echo 'Arnold disse uma vez: "I\'ll be back"'; // imprime Arnold disse uma vez: "I'll be back"

And as said in comments , if you do not know what a string is, then it is important that you study about, and master the subject completely , already that on all systems you will use this type of scalar variable .

    
25.08.2017 / 15:47