Sream States
State refers to the overall configuration of information
When you change a variable's value, you change the state. This may or may not affect a future step of the computation, but it probably does(otherwise, what is the point of the variable)
What is the state of a stream?
Good
Location in file
End of File
Bad
Problems with the stream itself
Internet goes down
Printer loses power
Any kind of crash or break
Input is not what is expected (Logical)
expected type A, got (incompatible) type B
Robustness
Recall that we want our programs to be robust.
i.e. they should not crash on unexpected input!
Streams store state information in flags (i.e. bits)
We can use stream state information to recover gracefully when there are problems with streams.


Last updated
Was this helpful?