zoukankan      html  css  js  c++  java
  • 如果“不可能发生”的事情的确发生了,则要 使用断言进行报警

    一般教科书都鼓励程序员们进行防错设计,但要记住这种编程风格可 能会隐瞒错误。

    当进行防错设计时,如果“不可能发生”的事情的确发生了,则要 使用断言进行报警。

     1 #include <iostream>
     2 #include <string.h>
     3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
     4 
     5 using namespace std;
     6 int main(int argc, char** argv) {
     7         //设置字符串
     8     char string[] = "Fill the string with something";
     9     cout<<"string:"<<string<<endl;
    10     char *p=strset(string,'*');
    11     cout<<"p     :"<<p<<endl;
    12     cout<<"string:"<<string<<endl;
    13 
    14     //按指定字符和指定数目设置字符数组
    15     char string1[] = "Fill the string with something";
    16     cout<<"string1:"<<string1<<endl;
    17     p=strnset(string1,'*',5);
    18     cout<<"p    :"<<p<<endl;
    19     cout<<"string1:"<<string1<<endl;
    20     return 0;
    21 }
  • 相关阅读:
    委托
    反射
    ADO.net五大对象
    DNS协议详解
    FTP协议详解
    .Net 多线程 异步编程 Await、Async和Task
    AsnycLocal与ThreadLocal
    Angular 6.X CLI(Angular.json) 属性详解
    Angular Npm Package.Json文件详解
    Npm常用命令整理
  • 原文地址:https://www.cnblogs.com/borter/p/9413642.html
Copyright © 2011-2022 走看看