C++ IO Tutorial

Click here to load reader

  • date post

    04-Jul-2015
  • Category

    Education

  • view

    708
  • download

    2

Embed Size (px)

description

IO tutorial on C++

Transcript of C++ IO Tutorial

2. Streams What? , C++ - streams ( bytes) , 3. Streams What? , C++ - streams ( bytes) , 4. Streams What? , C++ - streams ( bytes) , 5. Streams Why? 6. Streams Why? 7. Streams Why? 8. Streams How? C++ : standard / 9. Streams How? C++ : standard / 10. Streams How? C++ : standard / 11. Streams How? C++ : standard / 12. & , namespace std cin, cout, cerr istream ostream Include iostream header 13. & , namespace std cin, cout, cerr istream ostream Include iostream header 14. & , namespace std cin, cout, cerr istream ostream Include iostream header 15. cout cerr standard cout cerr 16. cout cerr standard cout cerr 17. cout cerr standard cout cerr 18. cin standard 19. 20. IO / , : ifstream (input file stream) ofstream (output file stream) fstream (file stream) Include fstream header 21. IO / , : ifstream (input file stream) ofstream (output file stream) fstream (file stream) Include fstream header 22. IO / , : ifstream (input file stream) ofstream (output file stream) fstream (file stream) Include fstream header 23. IO / , : ifstream (input file stream) ofstream (output file stream) fstream (file stream) Include fstream header 24. IO / , : ifstream (input file stream) ofstream (output file stream) fstream (file stream) Include fstream header 25. Error flags in streams 3 bits eofbit (EOF) badbit failbit (.. , ) 26. Error flags in streams 3 bits eofbit (EOF) badbit failbit (.. , ) 27. Error flags in streams 3 bits eofbit (EOF) badbit failbit (.. , ) 28. Error flags in streams 3 bits eofbit (EOF) badbit failbit (.. , ) 29. Error flags in streams bit, - ( eof, fail, bad ) - good set (1) bits - clear stream, , unset (0) error flags 30. Error flags in streams bit, - ( eof, fail, bad ) - good set (1) bits - clear stream, , unset (0) error flags 31. Error flags in streams bit, - ( eof, fail, bad ) - good set (1) bits - clear stream, , unset (0) error flags 32. ifstream 33. ifstream ifstream cin - good, C, -eof, close , 34. ifstream ifstream cin - good, C, -eof, close , 35. ifstream ifstream cin - good, C, -eof, close , 36. ifstream ifstream cin - good, C, -eof, close , 37. ifstream - peek , - ignore - getline 38. ifstream - peek , - ignore - getline 39. ifstream - peek , - ignore - getline 40. ifstream - getline char title[256]; in.getline (title,256); strings, getline string title; getline(in, title); 41. ifstream - getline char title[256]; in.getline (title,256); strings, getline string title; getline(in, title); 42. ifstream & input stream, get pointer - tellg get pointer - seekg ( fseek C) 43. ifstream & input stream, get pointer - tellg get pointer - seekg ( fseek C) 44. ifstream & input stream, get pointer - tellg get pointer - seekg ( fseek C) 45. ifstream & input stream, get pointer - tellg get pointer - seekg ( fseek C) 46. fstream 47. ofstream ofstream cout (buffered IO) - flush() buffer , , buffer 48. ofstream ofstream cout (buffered IO) - flush() buffer , , buffer 49. ofstream ofstream cout (buffered IO) - flush() buffer , , buffer 50. ofstream ofstream cout (buffered IO) - flush() buffer , , buffer 51. ofstream & output stream, put pointer - tellp put pointer - seekp ( fseek C) 52. ofstream & output stream, put pointer - tellp put pointer - seekp ( fseek C) 53. ofstream & output stream, put pointer - tellp put pointer - seekp ( fseek C) 54. ofstream & output stream, put pointer - tellp put pointer - seekp ( fseek C) 55. fstream 56. fstream data3.txt , 57. IO & binary files ifstream ofstream ( bytes ) - read ifstream, bytes - write ofstream, bytes, 58. IO & binary files ifstream ofstream ( bytes ) - read ifstream, bytes - write ofstream, bytes, 59. IO & binary files ifstream ofstream ( bytes ) - read ifstream, bytes - write ofstream, bytes, 60. IO Streams & Strings 61. IO Streams & Strings C++ stringstream string string stream Include sstream header 62. IO Streams & Strings C++ stringstream string string stream Include sstream header 63. IO Streams & Strings C++ stringstream string string stream Include sstream header 64. istringstream istringstream string , string atoi 65. istringstream istringstream string , string atoi 66. ostringstream ostringstream string , string itoa 67. ostringstream ostringstream string , string itoa 68. Reference cplusplus.com ifstream ofstream fstream getline string stringstream istringstream ostringstream 69. Streams & Inheritanceistreamostreamiostream fstreamstringstreamifstreamistringstreamofstreamostringstream 70. Streams more examples 71. Questions?