User Profile

Collapse

Profile Sidebar

Collapse
Jianwee
Jianwee
Last Activity: Apr 13 '10, 01:18 AM
Joined: Feb 26 '10
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Jianwee
    replied to using of POSIX threads
    in C
    Then is there any other way to detect keyboard inputs? For example, some C++ programs can be stopped with the Ctrl+C method. They are implementing some sort of thread to detect the keypress right?
    See more | Go to post

    Leave a comment:


  • Jianwee
    replied to using of POSIX threads
    in C
    Then should I use std::cin instead?
    See more | Go to post

    Leave a comment:


  • Jianwee
    started a topic using of POSIX threads
    in C

    using of POSIX threads

    Hi all,

    I have some questions regarding the usage of POSIX threads. I would like to ask:

    1) Is it possible if in a thread, I were to run a scanf function in order to change the value of a global variable?

    2) Do I use scanf or std::cin? And why?

    eg.
    Code:
    void 
    *detectKey(void *arg)
    {
        int y;
        scanf("%d",&y);
        while (y !=
    ...
    See more | Go to post

  • Banfa,

    Thx a lot! Your method works!
    See more | Go to post

    Leave a comment:


  • To Banfa: I have already declared the detectKey function at the very beginning of the mainloop.cpp, right below the include, so that should be a global function right? But I will try what you have suggested. Sorry for getting it wrong, I'm only starting out on C++ recently.

    To donbock: I will take a look at <pthread.h> as you suggested. Thanks.
    See more | Go to post

    Leave a comment:


  • Thx for the reply so far. Here's some info that might help:
    I'm running on Ubuntu 9.04.
    GCC 4.1.3
    G++ 4.1.3

    The whole error message is:
    error: arguement of type 'void (localnav::Main Loop::)(void*)' does not match 'void* (*)(void*)'

    As I am working on ORCA (open source code for robotics), the whole code is too long to be displayed. The code where the error is pointing to is at the pthread_create...
    See more | Go to post

    Leave a comment:


  • Jianwee
    started a topic another "does not match ‘void* (*)(void*)’" error
    in C

    another "does not match ‘void* (*)(void*)’" error

    Hi all,

    I have encountered the above said error for some time. I have researched for possible solutions and have discovered that the error means that the function that I am calling as a thread is a member function. I have already declared the function as a global function, but yet the error still appears. Can anyone help me out here? The code is below. Thx in advance.

    Code:
    #include <pthread.h>
    #include
    ...
    See more | Go to post
No activity results to display
Show More
Working...