Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please tell me how to make this code below work on onlinegdb.com, I can not get this c code to show the 0 s and

Please tell me how to make this code below work on onlinegdb.com, I can not get this c code to show the 0s and 1s, the only output i get is usage.a.out speed.Please show screenshots of how to exactly get this code to work or show a screenshot of the output you get using onlinegdb.com!
code:
#include
#include
#include
#include
#include
// Signal handler for Ctrl-C
void handle_sigint(int sig){
endwin();
exit(0);
}
int main(int argc, char *argv[]){
if (argc !=2){
printf("Usage: %s speed
", argv[0]);
return 1;
}
int speed = atoi(argv[1]);
if (speed 1|| speed >99){
printf("Speed must be between 1 and 99.
");
return 1;
}
// Initialize curses
initscr();
cbreak();
noecho();
curs_set(0);
timeout(100- speed); // Adjust speed
srand(time(NULL)); // Seed the random number generator
// Set up signal handler for Ctrl-C
signal(SIGINT, handle_sigint);
int max_x, max_y;
getmaxyx(stdscr, max_y, max_x);
while (1){
for (int x =0; x max_x; x++){
int r = rand()%3;
char ch =(r ==0)?'0' : (r ==1)?'1' : '';
mvaddch(0, x, ch);
}
scrollok(stdscr, TRUE);
scrl(1);
refresh();
}
// End curses mode
endwin();
return 0;
}
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions

Question

Explain why many households do not participate in the stock market.

Answered: 1 week ago