Text files store data as readable characters: the number 42 becomes "4" and "2" (2 bytes). Binary files store raw bytes: 42 is 0x2A (1 byte). Text is human-readable, binary is compact and fast.
Open in binary mode with ios::binary: ifstream file("data.bin", ios::binary);. This disables text translations (like Windows converting \n to \r\n). Binary mode reads/writes bytes exactly as stored.
Use text mode for config files, logs, and human-readable data. Use binary for images, serialized objects, or when size matters. Mixing modes (reading binary file as text) produces garbage output.