Thread: Giving instruction to an executing C code

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    14

    Giving instruction to an executing C code

    I've tried to think of a solution, but I can't do it without some help. Lets say I have a c code that is executing and splitting out data using printf() statements constantly. Is there a way I can change a variable within the program on-the-fly? Or at least instruct it to fetch another constant from a file that I modify? Thanks!

    for example, in the following code, I want to change the variable "variable_of_interest" while it is executing.

    Code:
    float variable_of_interest
    main(){
        extern float variable_of_interest;
        while(1){
            printf( "variable = %f\n", variable_of_interest);
        }
    }

  2. #2
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    Depending on the OS, yes. In Linux, for example, you could have a signal handler.

  3. #3
    Registered User
    Join Date
    Aug 2006
    Posts
    14
    ah. Is it like catching Ctrl+C? I've done that before.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Executing C++ Code at Runtime
    By jdm in forum C++ Programming
    Replies: 14
    Last Post: 10-18-2004, 05:32 PM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  3. True ASM vs. Fake ASM ????
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 04-02-2003, 04:28 AM
  4. ASM 'Out Instruction' crashes, code included.
    By Xei in forum C Programming
    Replies: 5
    Last Post: 03-03-2003, 05:42 PM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM