不仅要检查输入参数的有效性,还要检查通过其它途径进入函数体内 的变量的有效性
2023-09-14 09:12:03 时间
不仅要检查输入参数的有效性,还要检查通过其它途径进入函数体内 的变量的有效性,例如全局变量、文件句柄等。
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(¤t_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\n"); 28 29 for(int i=0;i<5;i++) { 30 time(¤t_time); 31 timep=ctime(¤t_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(¤t_time); 45 timep=ctime(¤t_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 }
相关文章
- C# 系统应用之获取IE浏览记录和IE地址栏输入网址
- 输入两个递增排序的链表,合并这两个链表并使新链表中的结点仍然是按照递增排序的
- 循环输入某同学 S1 结业考试的 5 门课成绩,并计算平均分
- 在Linux下SVN Check out时需要一直输入密码的问题
- Linux xshell窗口批量命令编辑功能(发送键输入到所有窗口)
- 控件repositoryItemTextEdit输入不上
- 【计组笔记08】计算机组成与原理之IO设备系统(输入、输出设备、外存储器)
- Python语言学习:Python语言学习之编程语言基础案例综合应用集合(输入带*号的密码/与用户交/根据分数判断优良差/提取txt文档中两人对话内容等)之详细攻略
- 习题 9.3 编写一个函数print,打印一个学生的成绩数组,该数组中有5个学生的数据记录,每个记录包括num,name,score[3],用主函数输入这些记录,用print函数输出这些记录。
- 习题 9.12 建立一个链表,每个结点包括:学号、姓名、性别、年龄。输入一个年龄,如果链表中的结点所包含的年龄等于此年龄,则将此结点删去。
- 解答私信@m0_64728212 //C 定义一个结构体变量(包括年、月、日)。计算该日在本年中是第几天,注意闰年问题。例如输入2008,8, 8,应输出是2008年中的第221天。
- VB编程:If-ElseIf判断输入的字符是数字还是字母-10_彭世瑜_新浪博客
- 【数字信号处理】线性时不变系统 LTI “ 输入 “ 与 “ 输出 “ 之间的关系 ( LTI 系统单位脉冲响应 | 卷积 | 卷积推导过程 )
- C语言 第二章 数据类型、变量和输入函数
- 如果输入参数采用“指针传递”,那么加 const 修饰可以防止意外地改动该指针,起 到保护作用
- win10快速输入当前日期与时间