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 }
  • 相关阅读:
    SCRUM站立会议
    燃尽图
    第一次作业----词频统计
    构建之法读感
    final 评论 II
    final 评论 I
    第十一周PSP
    学期回顾
    第十周PSP
    Gradle学习笔记
  • 原文地址:https://www.cnblogs.com/borter/p/9413623.html
Copyright © 2011-2022 走看看