zoukankan      html  css  js  c++  java
  • 不仅要检查输入参数的有效性,还要检查通过其它途径进入函数体内 的变量的有效性

    不仅要检查输入参数的有效性,还要检查通过其它途径进入函数体内 的变量的有效性,例如全局变量、文件句柄等。

     1 #include <iostream>
     2 
     3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
     4 #include<conio.h>
     5 #include <time.h>
     6 
     7 using namespace std;
     8 //定义时间延迟函数
     9 void Dtime(double dt) {
    10     time_t current_time;
    11     time_t start_time;
    12 
    13     // 得到开始时间
    14     time(&start_time);
    15     //延迟处理
    16     do 
    17     {
    18       time(&current_time);
    19     } 
    20     while (difftime(current_time,start_time)<dt);
    21 }
    22 
    23 //控制台函数显示
    24 void cputs_show(int n) {
    25     time_t current_time;
    26     char *timep;
    27     cputs("Show time with cputs
    ");
    28 
    29     for(int i=0;i<5;i++) {
    30         time(&current_time);
    31         timep=ctime(&current_time);
    32         cputs(timep);
    33         Dtime(n);
    34     }
    35 }
    36 
    37 //cout对象显示
    38 void cout_show(int n) {
    39     time_t current_time;
    40     char *timep;
    41     cout<<"Show time with cout"<<endl;
    42 
    43     for(int i=0;i<5;i++) {
    44         time(&current_time);
    45         timep=ctime(&current_time);
    46         cout<<timep;
    47         Dtime(n);
    48     }
    49 }
    50 
    51 //main()函数的定义
    52 int main(int argc, char** argv) {
    53    cputs_show(1);
    54     cout_show(1);
    55     return 0;
    56 }
  • 相关阅读:
    0929作业
    0909上机作业
    熟悉的LINUX操作
    博客搭建成功啦!
    感谢管理员,通过了我的博客邀请。哈哈
    Asp.net常用的51个代码(非常实用)
    CSS命名规范:
    常用的JavaScript验证正则表达式
    Linq to sql 查询句法
    Web.config配置文件详解
  • 原文地址:https://www.cnblogs.com/borter/p/9413623.html
Copyright © 2011-2022 走看看