- Joined
- Sep 20, 2022
- Messages
- 338
- Reaction score
- 42
Have any code you're not proud of? Let's have a laugh.
Read a word from a file, words are delimited by any amount of whitespace. Comments (counted as whitespace) begin with a semicolon and end at the next newline.
This is just plain lazy, I should lose the 3 exits and think up better conditions on my loops.
Read a word from a file, words are delimited by any amount of whitespace. Comments (counted as whitespace) begin with a semicolon and end at the next newline.
Code:
A = empty string
WHILE true
IF EOF
EXIT
B = read a byte
IF B == semicolon
WHILE B != newline
IF EOF
EXIT
B = read a byte
B = space
IF B is whitespace
IF A != ""
EXIT
ELSE
append B to A