An LPSTR is a Long Pointer to a STRing, it's basically a char*, a C string. The 16 bit x86 architecture has a notion of a near and far pointer which you can ignore these days.
So a string is an array of chars and the char* starts to the beginning of the range. Where does it end? Well it ends on the first zero, the null terminator. So the length isn't sizeof(char*) which is going to be 4 or 8, the length is strlen(text).
kbw You are right, I confused with LPTSTR, my apologies for that
However, I am not agree with you about this:
So a string is an array of chars and the char* starts to the beginning of the range. Where does it end? Well it ends on the first zero, the null terminator. So the length isn't sizeof(char*) which is going to be 4 or 8, the length is strlen(text).
Your advice about using strlen() is wrong, the buffer is NOT null-termionated. More likely you could use sizeof() if the array is created on the stack:
1 2 3
char buffer[4096] = {0};
fin.read (buffer, sizeof(buffer)); // this works more or less, sizeof(char) is always 1 on windows at least
fin.read (buffer, strlen(buffer)); // strlen will return 0 in this case, WRONG
However, this snippet willnot work with sizeof() if the buffer is allocated with new or malloc()