> For the complete documentation index, see [llms.txt](https://mentebinaria.gitbook.io/manual-da-linguagem-gnu-c/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mentebinaria.gitbook.io/manual-da-linguagem-gnu-c/7.-expressoes-de-atribuicao/atribuicao-simples.md).

# Atribuição Simples

Uma expressão de atribuição simples calcula o valor do operando à direita e o armazena no *lvalue* à esquerda. Aqui está uma expressão de atribuição simples que armazena 5 em `i`:

```c
i = 5
```

Dizemos que isso é uma atribuição para a variável `i` e que atribui a `i` o valor 5. Não tem ponto e vírgula porque é uma expressão (portanto, tem um valor). Adicionar um ponto e vírgula no final a tornaria uma instrução (veja [*Instrução de Expressão*](#user-content-fn-1)[^1]).

Aqui está outro exemplo de uma expressão de atribuição simples. Seus operandos não são simples, mas o tipo de atribuição feita aqui é uma atribuição simples.

```c
x[foo ()] = y + 6
```

Uma atribuição simples com dois tipos de dados numéricos diferentes converte o valor do operando à direita para o tipo do *lvalue*, se possível. Ela pode converter qualquer tipo numérico para qualquer outro tipo numérico.

A atribuição simples também é permitida em alguns tipos não numéricos: ponteiros (veja [*Ponteiros*](#user-content-fn-1)[^1]), estruturas (veja [*Atribuição de Structs*](#user-content-fn-1)[^1]) e uniões (veja[ *Uniões*](#user-content-fn-1)[^1]).

Aviso: A atribuição não é permitida em arrays porque em C não existem valores de array; variáveis em C podem ser arrays, mas esses arrays não podem ser manipulados como um todo. Veja [Limitações de Arrays em C](#user-content-fn-1)[^1].

Veja [*Conversões de Tipos em Atribuições*](#user-content-fn-1)[^1] para as regras completas sobre tipos de dados usados em atribuições.

[^1]: Capítulo pendente de tradução


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://mentebinaria.gitbook.io/manual-da-linguagem-gnu-c/7.-expressoes-de-atribuicao/atribuicao-simples.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
