It's part of the
deffinition when beeing called with either the string itself or a const char pointer, you won't conflict with the standard declaration of the ifstream constructor.
Since basicaly it's the same so the rolled back code will in your first case be:
- temporary const char pointer (temp) assigned value "example.txt"
- ifstream default constructor called with (temp) relying on default open flags
- file pointer assigned to (file)
Where in your second case it would be:
- static constant char pointer (filename) assigned value "example.txt"
- ifstream constructor taking (const char*, ios::flags) called with (filename, ios::in|ios::binary|ios::ate)
- file pointer assigned to (file)
As you see the implied code is virtualy the same, you just did a bit more coding in order to achieve the same result.
On a side note, if you're planing on reading into your
once you've opened the file, you will experience errors, the buffer has to have the needed memory assigned, either by usign malloc()/new() or by specifying the size needed as in your first example.