#include "pch.h"
#include <iostream>
#include <csignal>
#include <windows.h> using namespace std; int i; void signalHandle(int signum)
{
cout << "Interrupt signal(" << signum << ")received" << endl;
i = signum;
} int main()
{
//注册信号以及信号处理程序
signal(SIGINT, signalHandle); while (1)
{
if (i == 2)
{
break;
}
cout << "hello..." << endl;
Sleep(1000);//暂停1s
} system("pause");
return 0;
}

参考

https://blog.csdn.net/qq_28796345/article/details/51290493

Windows10 VS2017 C++信号处理的更多相关文章

  1. Windows10 VS2017 C++编译Linux程序

    #include <cstdio> #include <iostream> #include "unistd.h" using namespace std; ...

  2. Windows10 VS2017 C++使用crypto++库加密解密(AES)

    参考文章: https://blog.csdn.net/tangcaijun/article/details/42110319 首先下载库: https://www.cryptopp.com/#dow ...

  3. Windows10+VS2017 用GLFW+GLAD 搭建OpenGL开发环境

    本文参考:https://learnopengl-cn.github.io/ 一 下载GLFW(https://www.glfw.org/download.html)  和 GLAD(https:// ...

  4. Windows10 VS2017 C++多线程传参和等待线程结束

    #include "pch.h" #include <iostream> #include <windows.h> using namespace std; ...

  5. Windows10 VS2017 C++模拟点击按键

    #include "pch.h" #include <Windows.h> #include <stdio.h> #include <iostream ...

  6. Windows10 VS2017 C++ ini解析(使用simpleini头文件)

    simpleini项目地址: https://github.com/brofield/simpleini 下载,新建项目,并将SimpleIni.h文件通过包含目录的方式加载进来. 创建test.in ...

  7. Windows10 VS2017 C++ xml解析(tinyxml2库)

    首先下载tinyxml2 7.0.1库: https://github.com/leethomason/tinyxml2/releases 打开tinyxml2,然后升级sdk,解决方案->重定 ...

  8. Windows10 VS2017 C++ Json解析(使用jsoncpp库)

    1.项目必须是win32 2.生成的lib_json.lib放到工程目录下 3.incldue的头文件放到工程目录,然后设置工程->属性->配置属性->vc++目录->包含目录 ...

  9. Windows10 VS2017 C++ Server Socket简单服务器端与客户端

    服务端: #include "pch.h" #include<iostream> #include<WinSock2.h> #include <Ws2 ...

随机推荐

  1. codeforces #305 C Mike and Foam

    首先我们注意到ai<=50w 因为2*3*5*7*11*13*17=510510 所以其最多含有6个质因子 我们将每个数的贡献分离, 添加就等于加上了跟这个数相关的互素对 删除就等于减去了跟这个 ...

  2. web前端开发常用组件

    web前端开发常用组件 1. 对话框(dialog):jbox(适合对话框等其它功能).colorbox(也很强大,可以弥补jbox图片轮播的落点),      这二者基本能搞定所有对话框的情况 2. ...

  3. Linux 网络管理、软件包安装

    1.fdisk -l 查看处系统磁盘设备,打boot“*”的是系统启动的磁盘块. (1)查看磁盘Disk /dev/sdb:5368MB(总大小),5368709120bytes(比特位) (2)25 ...

  4. centos 安装php laravel框架

    centos6 安装 laravel 1 环境要求,lnmp(php5.4以上,重要的事情说三遍) 2 安装Composer curl -sS https://get****composer.org/ ...

  5. 剑指offer(8)跳台阶

    题目描述 一只青蛙一次可以跳上1级台阶,也可以跳上2级.求该青蛙跳上一个n级的台阶总共有多少种跳法. 题目分析 题目很简单,稍微分析就知道这是斐波那契数列,所以可以动态规划来做 a.如果两种跳法,1阶 ...

  6. onchange 事件

    Event 对象 定义和用法 onchange 事件会在域的内容改变时发生. 语法 onchange="SomeJavaScriptCode" 参数 描述 SomeJavaScri ...

  7. gitlab或github下fork后如何同步源的新更新内容?

    两种方式: 项目 fetch 到本地,通过命令行的方式 merge 懒人方法,只用 Github ,不用命令行 1.项目 fetch 到本地,通过命令行的方式 merge 提示:跟上游仓库同步代码之前 ...

  8. 模块——Getopt::Long接收客户命令行参数和Smart::Comments输出获得的命令行参数内容

     我们在linux常常用到一个程序需要加入参数,现在了解一下 perl 中的有关控制参数的模块 Getopt::Long ,比直接使用 @ARGV 的数组强大多了.我想大家知道在 Linux 中有的参 ...

  9. 关于window.onresize

    window.ss1 = function() { alert("aaa") } window.ss = function() { alert("bbb") } ...

  10. ActiveRecord Nested Atrributes 关联记录,对嵌套属性进行CURD

    设置了Nested attributes后,你可以通过父记录来更新/新建/删除关联记录. 使用: #accepts_nested_attributes_for class method. 例如: cl ...