strings
In Cairo, a string is a collection of characters stored in a felt252
. Strings can have a maximum length of 31 characters.
Examples of strings:
use debug::PrintTrait;
fn main() {
let x = 'Cairo is awesome';
x.print();
let c = 'A';
c.print();
}
To run this example, first copy the code in a new file and then run cairo-run --single-file file_name
in your terminal.
Try it out!
- Install the toolchain:
- For macOS and Linux, run our script:
curl -sL https://raw.githubusercontent.com/lambdaclass/cairo-by-example/main/build/installer.sh | bash -s 2.2.0
- For Windows and others, please see the official guide
- Run the example:
- Copy the example into a strings.cairo file and run with:
%!s(<nil>) strings.cairo