vendredi 29 mars 2019

Is there a way to control flow of C++ code from outside?

I have a sample code :

#include<iostream>
main()
{
    int i = 10; //Line 1
    std::cout<<" i : "<<i; //Line 2
}

I want to somehow insert another statement (lets say one more std::cout) between Line-1 and Line 2.

Direct way is to change the source code and add required line. But for my source code compilation takes lot of time, so i can't afford to change the code frequently. So i want an automatic way such that i will be able to execute any statement in any function from outside so that upon hitting that function it execute my newly given statement.

I am not sure if this is possible or not. But any direction in writing the original code in such a way that my requirement can be fulfilled would be helpful.

[for debugging prupose]

Aucun commentaire:

Enregistrer un commentaire