Anonymous user
Print debugging statement: Difference between revisions
+C
mNo edit summary |
(+C) |
||
Line 10:
* Show the print debugging statements in the language.
* Demonstrate their ability to track provenance by displaying information about source code (e.g., code fragment, line and column number).
=={{header|C}}==
<lang C>#include <stdio.h>
#define DEBUG_INT(x) printf( #x " at line %d\nresult: %d\n\n", __LINE__, x)
int add(int x, int y) {
int result = x + y;
DEBUG_INT(x);
DEBUG_INT(y);
DEBUG_INT(result);
DEBUG_INT(result+1);
return result;
}
int main() {
add(2, 7);
return 0;
}</lang>
{{out}}
<pre>
x at line 7
result: 2
y at line 8
result: 7
result at line 9
result: 9
result+1 at line 10
result: 10
</pre>
=={{header|Pyret}}==
|