Document of c-modernization-kit (calc) 1.0.0
Loading...
Searching...
No Matches
add.c
Go to the documentation of this file.
1
16
17#include <libcalcbase.h>
18#include <console-util.h>
19#include <stdio.h>
20#include <stdlib.h>
21
40int main(int argc, char *argv[])
41{
42 console_init();
43
44 if (argc != 3)
45 {
46 fprintf(stderr, "Usage: %s <arg1> <arg2>\n", argv[0]);
47 console_dispose();
48 return 1;
49 }
50
51 int arg1 = atoi(argv[1]);
52 int arg2 = atoi(argv[2]);
53 int result;
54
55 if (add(arg1, arg2, &result) != 0)
56 {
57 fprintf(stderr, "Error: add failed\n");
58 console_dispose();
59 return 1;
60 }
61
62 printf("%d\n", result);
63
64 console_dispose();
65 return 0;
66}
計算ライブラリ (静的リンク用) のヘッダーファイル。
int add(const int a, const int b, int *result)
2 つの整数を加算します。
Definition add.c:20
int main(int argc, char *argv[])
プログラムのエントリーポイント。
Definition add.c:40