Manipulating ASCII files


  • To transfer a string to the file, you declare an object to be a member of the ofstream class and initialize it to the filename that you want to use.
  • This initialization sets aside various resources for the file and accesses the file of that name on the disk.
  • You can use the insertion operator << to output text to the file.
  • As in C, there is no need to open or close the file. This is automatically done by the constructors and the destructors of the ostream class.
  • To see the text in the file you can display it with the DOS TYPE command or open the file in any editor.

    Stream<< Previous
    Next >> Reading An ASCII String File

    Our aim is to provide information to the knowledge seekers. 


    comments powered by Disqus


Footer1