📄 signal1.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 + -