Ok, so heres the thing.

Firstly I use windows operating system and the Borland C++ software.

My program has to do the following:-
1> Open a source code, which is in .cpp format.
2> Monitor the flow of execution and print a message for every occurrence of a semicolon [;]
3> Write the same to a text file.

I have a good idea about file handling and hence the third part is no trouble.

For the first part i am not sure if i have to use "system" command or "exec" command etc..

And lastly I have no idea how to do the second part. How can i monitor an execution of a program.

Example of my problem:-

If my source code is:-

void main()
{
  clrscr();
  int a=5,b=3;
  if(a>b)
    cout<<"a is greater";
  else
    cout<<"b is greater";
  getch();
}

so my program should execute this or run this or do anything to get the output:-
Line 1 is executed
Line 2 is executed
Line 4 is executed
Line 7 is executed

It should not say "Line 6 is executed", as it never has been.

I think you're actually writing a very small C++ interpreter ...

Well its like a small part of a project, any ideas on how to implement it?

I know a book where it's explained in: "The Art of C++" by Herbert Schildt ...

This seems to be what you need ...

Hmmmmmm... ok.. i'll check tat out.... thanks:)

The Art of C++ was a great book; regardless, perhaps you should turn it into a crude compiler that puts it into MASM32 mnemonic, or some other flow of choice.

Yeah you're absolutely right, but you've to know the basics of C++ ...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.