title: Do C standard library functions which are included in C++ throw exception?
body: <p>In the below code, author points that <code>new operator</code> function call might cause an exception so that this implementation is not exception safe because object state is already changed in the first line. </p>
  
  <pre><code>String &amp;String::operator =( const char *str ) {
      // state is changed
      delete [] s_;                                        
  
      if( !str ) str = "";
  
      // exception might occur because of new operator
      s_ = strcpy( new char[ strlen(str)+1 ], str );
  
      return *this;
  }
  </code></pre>
  
  <p>While reading, I wondered that do C library functions throw exception in C++ ? I know that there is no exception in C but since we are using C++ compiler, there might be exceptions. </p>
  
  <p>So, can we consider c standard lib functions as exception safe function calls ?</p>
  
  <p>Thank you.    </p>
  
  <p>Btw, for the record, right way (exception safe) to implement above function is below.</p>
  
  <pre><code>String &amp;String::operator =( const char *str ) {
      if( !str ) str = "";
      char *tmp = strcpy( new char[ strlen(str)+1 ], str );
      delete [] s_;
      s_ = tmp;
      return *this;
  }
  </code></pre>