Reading characters until the space key is pressed

Hello,
I want to write a program that receives data from the input and terminates the program as soon as the space key is pressed. I wrote the following program:

function space()
    print("Please write something: ")
    ch = 'a'
    while ch != ' '
        ch = read(stdin, Char)
    end
end

space()

Where is my code wrong?

Thank you.

You need to use the tricks linked in this other thread.

1 Like