ok i need help. read the code
why is (pbuffer - buffer) the number of characters in the buffer array. i know at the end of the program execution pbuffer has the address of '\0', but why does subtracting the address of '\0' to the buffer array equal the number of characters in the buffer array?Code:#include <iostream> using namespace std; int main() { const int MAX = 80; char buffer[MAX]; char* pbuffer = buffer; int i =0; cin.getline(buffer, MAX, '\n'); while(*pbuffer) { pbuffer++; } cout << "num of chars in buffer is " << (pbuffer - buffer); return 0; }
please do tell.!!!