File I/O

Read from and write to files. Use ifstream and ofstream to handle file data in your programs.

49 lessons
194 min

Lessons

1. Intro

Reading and writing files

4m

2. The fstream Header

File stream library

4m

3. What is ifstream?

Reading from files

4m

4. What is ofstream?

Writing to files

4m

5. Opening a File for Reading

Accessing existing files

4m

6. Quiz: Counter-based loop

Counter-based loop

3m1 problems

7. Opening a File for Writing

Creating and overwriting files

4m

8. Checking if File Opened Successfully

Validating stream state

4m

9. Quiz: Conditional execution

Conditional execution

3m1 problems

10. Quiz: Opening Files

Knowledge check

3m1 problems

11. Reading with >> Operator

Extracting formatted data

4m

12. Reading Line by Line

Handling full lines

4m

13. Reading Word by Word

Processing individual tokens

4m

14. Reading Character by Character

Byte-level file access

4m

15. Quiz: Character type

Character type

3m1 problems

16. Writing with << Operator

Formatted output to files

4m

17. Writing Lines

Structured text output

4m

18. Closing Files

Resource cleanup

4m

19. Quiz: Reading Methods

Knowledge check

3m1 problems

20. File Modes

Controlling open behavior

4m

21. Appending to Files

Preserving existing content

4m

22. Binary vs Text Files

Understanding file formats

4m

23. Reading Binary Data

Raw byte input

4m

24. Quiz: Knowledge check

Knowledge check

3m1 problems

25. Writing Binary Data

Raw byte output

4m

26. Quiz: Binary Mode

Knowledge check

3m1 problems

27. File Position

Random access navigation

4m

28. tellg and tellp

Querying current position

4m

29. Checking End of File

Detecting file boundaries

4m

30. Common File I/O Patterns

Standard code templates

4m

31. Quiz: Knowledge check

Knowledge check

3m1 problems

32. Error Handling with Files

Detecting and recovering

4m

33. Quiz: Error States

Knowledge check

3m1 problems

34. RAII and File Streams

Automatic resource management

4m

35. Practice: Copy File Contents

Read and write exercise

4m

36. Practice: Count Lines in File

File analysis exercise

4m

37. Quiz: File I/O Patterns

Knowledge check

3m1 problems

38. Problem - Word Counter

File input basics

4m1 problems

39. Word Counter - The Idea

File reading pattern

5m

40. Word Counter - Algorithm

Implementation approach

4m

41. Word Counter - Implementation

Pseudocode solution

7m1 problems

42. Lessons from Word Counter

summary

4m

43. Problem - Log Analyzer

File output basics

4m1 problems

44. Log Analyzer - The Idea

File writing pattern

5m

45. Log Analyzer - Algorithm

Implementation approach

4m

46. Quiz: Knowledge check

Knowledge check

3m1 problems

47. Log Analyzer - Implementation

Pseudocode solution

7m1 problems

48. Lessons from Log Analyzer

summary

4m

49. Section Recap

What we learned

5m

Ready to start learning?

Access all 49 lessons with interactive content and progress tracking.