Thread: how to simulate keyboard actions to a sub-thread

  1. #1
    Registered User
    Join Date
    Oct 2005

    Question how to simulate keyboard actions to a sub-thread

    Hi guys, we decided to create a on-line judging system, the user submits a piece of code and our system compiles it and run it with some test data and the results will be returned to let the user know. we think of using two thread to do this. the main thread supervises the sub-thread and the sub-thread is the user code. but the question is how to convey the test date through the main thread to the sub-thread? the user's code will be compiled into some DOS application, and it receives the test code through functions like "scanf" or "cin".

    a sample of the system can be found at

  2. #2
    Registered User
    Join Date
    Jan 2005
    Redirect the program's standard input that way calls to scanf and cin won't take input from the console they can take input from a file or pipe.
    You can do this in the STARTUPINFO structure that you pass to CreateProcess.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Terminating secondary thread from another thread
    By wssoh85 in forum C++ Programming
    Replies: 13
    Last Post: 12-19-2008, 05:14 AM
  2. Thread Prog in C language (seg fault)
    By kumars in forum C Programming
    Replies: 22
    Last Post: 10-09-2008, 01:17 PM
  3. Calling a Thread with a Function Pointer.
    By ScrollMaster in forum Windows Programming
    Replies: 6
    Last Post: 06-10-2006, 08:56 AM
  4. pointer to main thread from worker thread?
    By draegon in forum C++ Programming
    Replies: 2
    Last Post: 10-27-2005, 06:35 AM
  5. Critical Sections, destroying
    By Hunter2 in forum Windows Programming
    Replies: 4
    Last Post: 09-02-2003, 10:36 PM