Document of c-modernization-kit (calc) 1.0.0
Loading...
Searching...
No Matches
divide.c File Reference

divide 関数の実装ファイル。 More...

#include <libcalcbase.h>
#include <stddef.h>
Include dependency graph for divide.c:

Go to the source code of this file.

Functions

int divide (const int a, const int b, int *result)
 2 つの整数を除算します。

Detailed Description

divide 関数の実装ファイル。

Author
c-modenization-kit sample team
Date
2025/11/22
Version
1.0.0

2 つの整数を除算する関数を提供します。

Definition in file divide.c.

Function Documentation

◆ divide()

int divide ( const int a,
const int b,
int * result )

2 つの整数を除算します。

Parameters
[in]a被除数。
[in]b除数。
[out]result計算結果を格納するポインタ。
Returns
成功時は CALC_SUCCESS、失敗時は CALC_SUCCESS 以外の値を返します。

この関数は 2 つの整数を受け取り、その商を result に格納します。 整数除算のため、小数点以下は切り捨てられます。

使用例
int result;
if (divide(20, 4, &result) == CALC_SUCCESS) {
printf("Result: %d\n", result); // 出力: Result: 5
}
#define CALC_SUCCESS
成功の戻り値を表す定数。
int divide(const int a, const int b, int *result)
2 つの整数を除算します。
Definition divide.c:20
Warning
ゼロ除算の場合、または result が NULL の場合は失敗を返します。

Definition at line 20 of file divide.c.

References CALC_ERROR, and CALC_SUCCESS.

Referenced by calcHandler(), and main().

Here is the caller graph for this function: