I'd like to write C++ program that will count the number of times each line of the code get executed
can any one help me
thanks in advance
I suppose if you have a program that contains 1,000 lines you should have an int array of 1,000 ints and do something like this
int counters[1000] = {0};
int main()
{
counters[__LINE__]++;
cout << "Hello World\n";
counters[__LINE__]++;
return 0;
};
__LINE__ is a macro that returns the current line number of the program. I'm not certain if that macro is available on all compilers or not.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.