Read Modern C and see this C reference
Your scanf
statement should be (using the &
prefix "address-of" operator):
scanf("%d,%d",&a,&b);
and your code is incomplete, since scanf
can fail. You should read its documentation.
Consider coding a test against such failure using:
if (scanf("%d,%d", &a, &b) < 2) {
perror("scanf failure");
exit(EXIT_FAILURE);
}
Read also the documentation of your C compiler, e.g. GCC, and of your debugger, e.g. GDB. You could compile your code with gcc -Wall -Wextra -g
to get all warnings and debug information, and later use gdb
to debug your executable and understand its runtime behavior.
Your code is missing a #include <stdio.h>
before your main
.
The printif
is wrong. You want to use printf
(and read its documentation).
Consider studying for inspiration the source code of some existing free software, such as GNU make or GNU bash.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…