Unlike puts , gets doesn't have a default channel. Writing to a file Similar to the channel used in gets , the puts command can be given a channel to write to. When not given a channel argument, puts defaults to the stdout channel We'll need to create the channel before using it. What a surprise. It works the same way puts did, only in reverse using gets .
Basic syntax is same as before.
Still need to open and assign the channel. I wrote out to in the last example. It's always good to explicitly close a file that's been opened when you're done with it. Reason is some OS's use what's known as output buffering, in which output gets buffered in a temporary holding place until there's 'enough' of it at which time it gets written out to the appropriate location. The basic command is the string command.