Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Can pthread.h and ncurses.h work together?

mr_jackmr_jack Member Posts: 11
[b][red]This message was edited by mr_jack at 2006-10-19 4:48:40[/red][/b][hr]
[b][red]This message was edited by mr_jack at 2006-10-19 4:48:13[/red][/b][hr]
Hello everybody!

I have a problem with pthread and ncurses library:

I'm writing a C program that need to move the cursor in the screen and
job with multithread, then i have included pthread.h and ncurses.h in the following simple program to try them, but it seems doesn't RUN (i have compiled it without problems)... PLEASE HELP ME!!!!! I have used last gcc release with -lpthread and -lncurses options....


/* Parameters to print_function. */
struct char_print_parms
/* The character to print. */
char character;
/* The number of times to print it. */
int count, x;
//WINDOW * output;

void * char_print (void * parameters);

int main (){

pthread_t thread1_id;
pthread_t thread2_id;
struct char_print_parms thread1_args;
struct char_print_parms thread2_args;


/* Create a new thread to print 30 x's. */
thread1_args.character = 'x';
thread1_args.count = 30;
thread1_args.x = 1;
printw("%c, %d, %d
", thread1_args.character, thread1_args.count, thread1_args.x);
//printf("%c, %d, %d
", thread1_args.character, thread1_args.count, thread1_args.x);
//pthread_create(&thread1_id, NULL, &char_print, &thread1_args);

/* Create a new thread to print 20 o's. */
thread2_args.character = 'o';
thread2_args.count = 20;
thread2_args.x = 1;
printw("%c, %d, %d
", thread2_args.character, thread2_args.count, thread2_args.x);
//printf("%c, %d, %d
", thread2_args.character, thread2_args.count, thread2_args.x);
//pthread_create(&thread2_id, NULL, &char_print, &thread2_args);

/* Make sure the first thread has finished. */
//pthread_join(thread1_id, NULL);
/* Make sure the second thread has finished. */
//pthread_join(thread2_id, NULL);

/* Now we can safely return. */

return 0;

/* Prints a number of characters to stdout, as given by PARAMETERS,
which is a pointer to a struct char_print_parms. */
void * char_print (void * parameters)
/* Cast the cookie pointer to the right type. */
struct char_print_parms * p = (struct char_print_parms *) parameters;
int i;
for (i = 0; i < p->count; ++i){

return NULL;

Sign In or Register to comment.