Skip to content

Reading

Lucas Menezes edited this page Apr 26, 2020 · 6 revisions

Reading

The command # variable is used to read from stdin into the variable.

The # behaves differently depending on the type of variable.

Limits

Variable can only read input up to their maximum value.

Bytes can only read between 0 to 255, shorts can go from 0 to 65535 and ints can go up to 4294967295.

Variables of type char reads the character as character, in instead of a number; Acts as wrapper of the , instruction

Reading an input number greater than variable's type supports is undefined behavior.

Example

void main(){
    byte a;
    @"Please enter a 8 bit number:"
    #a;
    @"Variable a receives ";@a;@" from input.\n";
}

Alternative

The # can be swapped for read

In fact:

#x;
read x;

are both valid and are the same command in Headache.

Clone this wiki locally