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

Asked

Viewed 1,107 times

-2

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

  • Some general aspects of the type string?
  • A little about their use, where and how they are used?
  • I wanted a more brief definition to explain what a string? In a nutshell for someone more lay.
  • 3

    Uma string é uma sequência de zero ou mais caracteres. É comumente utilizada para representar texto ou uma sequência de bytes. Ao marcar uma pergunta com essa tag, marque também com a linguagem de programação a ser utilizada e a operação que está sendo tentada com a string. basically you are asking: "What is the importance of the text?"

  • 1

    String nothing more than a string of characters. Your question is out of focus of the purpose of the site. Good luck!

  • 1

    Estou começando a programar, porém, ainda não sei o valor ou importância da string na programação. You haven’t started programming yet.

1 answer

6

Short Answer

You will write something (texts, phrases, words, characters) to your user?

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


Answer not so short

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

In most programming languages, the strings can be expressed either literally or through some kind of variable. When expressed through variables, the content of the string can usually be changed by the inclusion/exclusion of elements or by the substitution of their elements by other elements, forming a new string.

Basically it is like a type of data and is usually implemented through an arrangement of bytes which stores chain elements in sequence, using some pre-established encoding.

Text taken from the tag wiki .


Since you didn’t mark a programming language, I’ll give it to you examples in PHP:

The simplest way to specify a string is to delimit it between single quotes (the character ').

A literal string can be specified in four different ways:

  • single quotes
  • double quotes
  • heredoc syntax
  • Nowdoc syntax (since PHP 5.3.0)

Single 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 as well:

$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 the comments, if you don’t know what a string, then it is important that you study about, and master completely the subject, since in all systems you will use this type of scalar variable.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.