NEWTON
Asked
6 months ago
68
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
6 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
6 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?
ApeWorX: Why do I need to fund a Starknet account before deploying it?
Can you explain what is Abstract Account?
How to select the network my Pathfinder node runs on?
Is Kakarot a Starkware project?
How do I create my own account abstraction using starknetjs?
Cairo: Expected '__main__.Id' to be a struct. Found: 'future'
Why abi of warp compiled contract does not match original solidity abi?