title: Why this below code is throwing an error "Abort signal from abort(3) (SIGABRT)"?
body: <p>Question :- Write a program to Validate an IPv4 Address. According to Wikipedia, IPv4 addresses are canonically represented in dot-decimal notation, which consists of four decimal numbers, each ranging from 0 to 255, separated by dots, e.g., 172.16.254.1 . The generalized form of an IPv4 address is (0-255).(0-255).(0-255).(0-255). Here we are considering numbers only from 0 to 255 and any additional leading zeroes will be considered invalid.
  Your task is  to complete the function isValid which returns 1 if the ip address is valid else returns 0. The function takes a string s as its only argument .</p>
  <p>Code:</p>
  <pre class="lang-cpp prettyprint-override"><code>   class Solution {
      public:
          int isValid(string s) {
              // code here
              if(s.size() == 0 || s.size() &gt; 15){
                  return 0 ;
              }
              string temp = &quot;&quot;;
              int dot = 3 ;
              for(int i = 0 ; i &lt; s.size() ; i++){
                  if(temp.size() &gt; 3){
                      return 0 ;
                  }
                  if(s[i] == '.'){
                      if(temp.size() == 0){
                          return 0 ;
                      }
                      else{
                          if(temp.size() != to_string(stoi(temp)).size() || stoi(temp) &gt; 255){
                              return 0 ;
                          }
                      }
                      temp.clear() ;
                      dot--;
                  }
                  else {
                      if((s[i]-'0')&gt;= 0 &amp;&amp; (s[i]-'0')&lt;=9){
                       temp.push_back(s[i]) ;   
                      }
                      else{
                          return 0 ;
                      }
                  }
              }
              if(temp.size() != to_string(stoi(temp)).size() || stoi(temp) &gt; 255 || dot != 0){
                  return 0 ;
              }
              return 1 ;
          }
  };
  </code></pre>
  <p>This code is working fine for all the testcases and all the testcases I give as input myself but on submitting, it gives Runtime Error.</p>