The ifx_int8cvint() function

The ifx_int8cvint() function converts a C int type number into an int8 type number.

Syntax

mint ifx_int8cvint(int_val, int8_val)
   mint int_val;
   ifx_int8_t *int8_val;
int_val
The mint value that ifx_int8cvint() converts to an int8 type value.
int8_val
A pointer to the int8 structure where ifx_int8cvint() places the result of the conversion.

Return codes

0
The conversion was successful.
<0
The conversion failed.

Example

The file int8cvint.ec in the demo directory contains the following sample program.
/*
   * ifx_int8cvint.ec *

    The following program converts two integers to INT8
    types and displays the results.
*/

#include <stdio.h>

EXEC SQL include "int8.h";

char result[41];

main()
{
    mint x;
    ifx_int8_t num;

    printf("IFX_INT8CVINT Sample ESQL Program running.\n\n");

    printf("Integer 1 = 129449233\n");
    if (x = ifx_int8cvint(129449233, &num))
        {
        printf("Error %d in converting int1 to INT8\n", x);
        exit(1);
        }

/* Convert int8 to ascii to display value. */

    if (x = ifx_int8toasc(&num, result, sizeof(result)))
        {
        printf("Error %d in converting INT8 to string\n", x);
        exit(1);
        }
    result[40] = '\0';
    printf("  The INT8 type value is = %s\n", result);

    printf("Integer 2 = -33\n");
    if (x = ifx_int8cvint(-33, &num))
        {
        printf("Error %d in converting int2 to INT8\n", x);
        exit(1);
        }

/* Convert int8 to ascii to display value. */

    if (x = ifx_int8toasc(&num, result, sizeof(result)))
        {
        printf("Error %d in converting INT8 to string\n", x);
        exit(1);
        }
    result[40] = '\0';
    printf("  The second INT8 type value is = %s\n", result);

    printf("\nIFX_INT8CVINT Sample Program over.\n\n");
    exit(0);
}

Output

IFX_INT8CVINT Sample ESQL Program running.

Integer 1 = 129449233
  The INT8 type value is = 129449233
Integer 2 = -33
  The second INT8 type value is = -33

IFX_INT8CVINT Sample Program over.