
例子:
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 int main(int argc, char **args)
5 {
6 printf("请输入两个整数:(a.out a b)\n");
7 if(argc <= 2)
8 return 0;
9 int a = atoi(args[1]);
10 int b = atoi(args[2]);
11 printf("%d + %d = %d\n", a, b, a+b);
12
13 return 0;
14 }
~
本文介绍了一个使用C语言编写的简单加法程序。该程序通过命令行接收两个整数参数,并输出这两个整数的和。文章展示了如何利用标准输入输出函数以及atoi函数将字符串转换为整型。
2387

被折叠的 条评论
为什么被折叠?



