小编cod*_*aty的帖子

Why runtime error occur when we try to get the length of the NULL string?

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?

c++ string pointers

-3
推荐指数
1
解决办法
121
查看次数

标签 统计

c++ ×1

pointers ×1

string ×1