> For the complete documentation index, see [llms.txt](https://cs4998.cornellblockchain.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cs4998.cornellblockchain.org/introduction/hello-world-pt.-2/dynamic-arrays-and-strings/strings.md).

# Strings

Having seen dynamic types in action (via dynamic arrays), it is time that we look at the type that has been absent from our discussion of the Solidity programming language: strings. Like most other programming languages, Solidity allows us to write literal text via strings, which have no size restriction.

As with most programming languages, strings in Solidity are an array of characters (represented by a byte); below is the syntax to declaring a string:

```solidity
string M stringName;
```

where `M` is the location of the string; below are the following locations where a string can be defined:

* `memory`: within the body of a function and as a function parameter
* `calldata`: as a function parameter

Below is a code snippet which uses strings extensively:

```solidity
contract StringExample {

    string name = "John";
    
    function getName() public view returns(string memory) {
        return name;
    }
    
    function setName(string calldata _name) public {
        name = _name;
    }

}
```


---

# 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://cs4998.cornellblockchain.org/introduction/hello-world-pt.-2/dynamic-arrays-and-strings/strings.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.
