add rand number
This commit is contained in:
parent
1a336d46e3
commit
82f5a40a87
23
src/main.c
23
src/main.c
@ -1,10 +1,22 @@
|
||||
#include <ncurses.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
void update(WINDOW *win)
|
||||
void get_data(int *speed, int *capacity)
|
||||
{
|
||||
*speed = rand() % 201;
|
||||
*capacity = rand() % 101;
|
||||
}
|
||||
|
||||
void update(WINDOW *win, int data)
|
||||
{
|
||||
int win_y, win_x;
|
||||
char message[] = "test";
|
||||
char message[64];
|
||||
snprintf(message, sizeof(message), "%d", data);
|
||||
|
||||
werase(win);
|
||||
box(win, 0, 0);
|
||||
|
||||
getmaxyx(win, win_y, win_x);
|
||||
mvwprintw(win, win_y/2, win_x/2 - strlen(message)/2, "%s", message);
|
||||
wrefresh(win);
|
||||
@ -16,6 +28,7 @@ int main()
|
||||
noecho();
|
||||
cbreak();
|
||||
curs_set(0);
|
||||
nodelay(stdscr, true);
|
||||
|
||||
int y,x;
|
||||
getmaxyx(stdscr, y, x);
|
||||
@ -33,11 +46,13 @@ int main()
|
||||
wrefresh(top_win);
|
||||
wrefresh(bottom_win);
|
||||
|
||||
int speed, capacity;
|
||||
int ch = ERR;
|
||||
while(ch == ERR)
|
||||
{
|
||||
update(top_win);
|
||||
update(bottom_win);
|
||||
get_data(&speed, &capacity);
|
||||
update(top_win, speed);
|
||||
update(bottom_win, capacity);
|
||||
ch = getch();
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user