Skip to content

No print output after using Pointer #2106

Closed Locked Answered by Moosems
Moosems asked this question in Q&A
Discussion options

You must be logged in to vote

I got it working:

from memory.unsafe import Pointer


@value
@register_passable("trivial")
struct Pair:
    var a: Int
    var b: Pointer[Int]


def main():
    var ex_a = 5
    var ex_b = Pointer[Int].alloc(1)
    ex_b[0] = 5
    var ex_pair = Pair(ex_a, ex_b)
    print(ex_pair.a)
    print(ex_pair.b.load())
    print("Worked?")

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Moosems
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant