📄 command.txt
字号:
Assignment 3 for comp170/570, semester 1, 2007. Due 2/6/7
Specification
-------------
Write a screen handling program to provide a flashing message.
You will have to design a screen layout for where messages
are placed on the screen. You will also have to consider
when to delay the program in order to give the user time
to read the messages. That is, the program will use the
curses library, signals and the sleep function.
Screen Layout and Program Operation
-----------------------------------
The screen should look something like this:
Flashing Message
Set new flash time:
Run the program with the flash time and message on the command line:
$ flash 2 "Flashing Message"
The message should flash on and off every 2 seconds.
The user may also change the flash time by entering a number
followed by <Enter>
The program should run in an infinite loop getting a new flash time
but while this is happening, the message continues to flash.
The user terminates the program by <ctrl>C thus sending the
SIGINT signal. The program should display a termination
message and exit.
Modularity.
----------
flasher.h
this file should contain #define screen coordinates for sections
of your screen layout.
For example
#define MESSAGE_ROW 6
#define MESSAGE_COL 10
flasher.c
this file should contain the function that
reads a new flash time from the screen.
main.c
this file should contain the main function, which calls the function
in flasher.c, and handler functions for SIGARLM and SIGINT.
makefile
You will also need a makefile so that the make utility can be used
to build the program.
Hints
-----
You may need to use these functions from the curses library
move
mvprintf
scanw
refresh
You may need to use this function from #include <stdlib.h>
exit(0);
You may need to use these functions from #include <signal.h>
signal
alarm
Since you can't pass parameters to signal handling functions,
declare the flashtime and message as global variables so that
they can be accessed by any function in main.c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -