Exception Qt或任何C应用程序中的异常处理

Exception Qt或任何C应用程序中的异常处理,exception,try-catch,Exception,Try Catch,我想在C中抛出异常处理,而不是在C或Qt平台中崩溃我的应用程序。 下面是我的示例代码 int main() { char *str; /* Stored in read only part of data segment */ str = "GfG"; /* Problem: trying to modify read only memory */ *(str+1) = 'n'; return 0

我想在C中抛出异常处理,而不是在C或Qt平台中崩溃我的应用程序。 下面是我的示例代码

 int main() 
{ 
   char *str;  
   
   /* Stored in read only part of data segment */
   str = "GfG";      
   
   /* Problem:  trying to modify read only memory */
   *(str+1) = 'n';  
   return 0; 
}
执行时会出现分段错误(内核转储)

通过使用try-catch,如何消除异常,即我的应用程序最终不会崩溃

先谢谢你