NEWTON
Asked
4 months ago
63
views
0
Hey folks, do you know how I could read a felt* from ap?
I want to do something like this:
let (hello : felt*) = alloc(); tempvar world : felt* = hello; let world_like : felt* = [ap-1];
when I do tempvar world = hello, I ensure I add hello (the pointer) to [ap] and then I increase ap so world_like = [ap-1] should be the same thing than world
But I get this error:
Cannot assign an expression of type 'felt' to a reference of type 'felt*'.
let world_like : felt* = [ap-1];
When doing a similar code:
let (func_pc: felt*) = get_label_location(storage_var); _prepare_call(pedersen_ptr, range_check_ptr, len_inputs, inputs + len_inputs); call abs ap[11 - 6 * 2];
I get ``` Cannot apply subscript-operator to non-pointer, non-tuple type 'felt'. call abs ap[11 - 6 * 2]; // removing alloc_locals by calling ap[11-6*2] ?
_This question was originally posted on [StarkNet Discord](https://www.newton.so/view?tags=discord)_
Newton
asked
4 months ago
0
Accepted answer
have you tried let world_like : felt* = cast([ap-1], felt*);
?
This answer was originally posted on StarkNet Discord
Newton
answered
4 months ago
Revoked References exercise from Cairo-lang
a pointer with a hint, without doing a memory allocation
A switch statement in Cairo lang to set two distinct values
storage for array
What is the inefficiency in this cairo code using alloc_locals
How can I pass an array of felt to call with Nile in StarkNet?
Are you able to nest mappings in Cairo like you can in Solidity?
Cairo: Javascript API for cairo compile
Cairo: Getting the squared summation of felts in an array
My Alchemy dashboard usage is low?
How do you check if a number is even in Cairo?
ApeWorX: Why are the cairo and starknet plugins not installing properly?
Is there any issue between using 4.4 and 3.x starknet.js?
A plan to get better visibility when a transaction got received but not placed into a block?