#include<stdio.h>
int main(int argc, char **argv)
{
int a,b,c;
printf("enter two numbers:-");
if( scanf("%d \t %d",&a,&b) == 2 )
{
c=a+b;
printf("addition of numbers= %d",c);
}
else {
printf("please enter a valid input");
getchar();
}
}
How to debug this code line by line in the c-debugger?
I’m using linux platform.
Which debugger? In MS Visual Studio Express just place a breakpoint at the first line of the code and then start “Debug”.
On a Linux platform, compile the code with debugging flags (
-g) and then run the resulting executable undergdb.Suppose your file is
test.c. Compile:Then debug:
See this article for more details. Google “linux debug c program” for even more.