⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 signal1.c

📁 嵌入式Linux程序设计与应用案例 电子书源码 中国电力出版社
💻 C
字号:
/***********
// name : signal1.c
// author : pyy
// date : 2007-11-22
**************/

#include<signal.h>
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/wait.h>
#include<sys/types.h>
struct product
{
    char str[100];
    float price;	
};

struct product p1;

/* signal processing function*/
void mess(int sig)
{
    printf("signal num: %d \n",sig);
    printf("product name: %s\n",p1.str);
    printf("price: %.2f\n",p1.price);
    printf("tax price: %.2f\n",p1.price*1.05);
    /* */
    (void) signal(SIGINT, SIG_DFL);	
	
}

int main()
{
    (void) signal(SIGINT,mess);
     printf("input name:");
     scanf("%s",&p1.str);
     printf("input price:");
     scanf("%f",&p1.price);
     while(1)
     {
         printf("Press CRTL-C\n"); sleep(2);	
     }	
     exit(0);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -