If a file stream object is constructed with a string or C-string as an argument, opening the file for
reading and/or writing is attempted automatically. Whether this attempt was successful is reflected
in the stream’s state. Thus, the state should be examined after construction.
The following program first opens the file charset.out, writes the current character set — all
characters for the values between 32 and 255— into this file, and outputs its contents: