I would like to iterate through the bytes of a file stream. I am using ifstream class. When you use the read function, it copies characters from the stream into the array that I specify in the argument list. I have 3 questions.
int length = 1024;
char buff[1024];
ifstream inf(fp, ios::in | ios::binary);
inf.read(buff, length);
The reason why I do not need to use "&" before "buff" is because the first parameter is not a pointer but a reference?
And what if I have this:
int length = 1024;
vector<char> buffer;
ifstream inf(fp, ios::in | ios::binary);
inf.read(&buff[0], length);
What it actually does is that it takes the memory address of the first element of the vector. Only the address of the first! But it still has access to the whole array because it copies the characters into it. How is it possible? Does the same thing apply to the following as well?:
int length = 1024;
char* buffer[1024];
ifstream inf(fp, ios::in | ios::binary);
inf.read(&buff[0], length);
Here, how do I access the array elements?