Posts

Showing posts with the label programming

C++ File and Stream Input/output

Image
in this post i am describing c++ file and stream input/output. you can try it your self, File I/O is based on streams. <fstream.h> must be included in your program First operation is to open file ·           ofstream outFile(char* filename,enum open_mode mode); ·           ifstream inFile(char* filename,enum open_mode mode);   open_mode  is optional and defined in ios.h for appending, nocreate, noreplace Test if open operation was successful ·           if(!outputFile) ·               // error occurred during open   Use << for output and >> for input Output and input operators defined for standard types Useful to provide << for your own classes ·           friend ostream& opeator<<(ostream& s,YourClass& c)   Use getline() or gets() members to read lines of text. ·           inFile.getline(char* buffer,int size,char delimiter); ·           inFile.gets(char** addrOfPtrToChar,char delimiter);   With getline() you specify buffer and maximum si

C++ File and Stream Input/output

Image
in this post i am describing c++ file and stream input/output. you can try it your self, File I/O is based on streams. <fstream.h> must be included in your program First operation is to open file ·             ofstream outFile(char* filename,enum open_mode mode); ·             ifstream inFile(char* filename,enum open_mode mode);   open_mode  is optional and defined in ios.h for appending, nocreate, noreplace Test if open operation was successful ·             if(!outputFile) ·                 // error occurred during open   Use << for output and >> for input Output and input operators defined for standard types Useful to provide << for your own classes ·             friend ostream& opeator<<(ostream& s,YourClass& c)   Use getline() or gets() members to read lines of text. ·             inFile.getline(char* buffer,int size,char delimiter); ·             inFile.gets(char** addrOfPtrToChar,char