Why the following code gives an error?
// This a CPP Program
#include <bits/stdc++.h>
using namespace std;
// Driver code
main()
{
string s=NULL;
s.length();
}
Run Code Online (Sandbox Code Playgroud)
I know that a runtime error will occur because I am trying to get the length of the null string but I want to know why it is happening?