demo 目录中的文件 int8tolong.ec 包含下列样例程序。 /* * ifx_int8tolong.ec * The following program converts three strings to INT8 types and converts the INT8 type values to C long type values.Then the values are displayed.
main() { int x; long l =0; ifx_int8_t num1, num2, num3;
GBase 8s ESQL/C 编程指南 南大通用数据技术股份有限公司 - 768 -
printf("IFX_INT8tOLONG Sample ESQL Program running.\n\n");
if (x = ifx_int8cvasc(string1, strlen(string1), &num1)) { printf("Error %d in converting string1 to INT8\n", x); exit(1); } if (x = ifx_int8cvasc(string2, strlen(string2), &num2)) { printf("Error %d in converting string2 to INT8\n", x); exit(1); } if (x = ifx_int8cvasc(string3, strlen(string3), &num3)) { printf("Error %d in converting string3 to INT8\n", x); exit(1); } printf("\nConverting INT8 to long\n"); if (x= ifx_int8tolong(&num1, &l)) { printf("\tError %d in converting INT8 to long\n", x); exit(1); } else { printf("String 1= %s\n", string1); printf("INT8 value is = %d\n", l); }
printf("\nConverting second INT8 to long\n"); if (x= ifx_int8tolong(&num2, &l)) {
GBase 8s ESQL/C 编程指南 南大通用数据技术股份有限公司 - 769 -
printf("\tError %d in converting INT8 to long\n", x); exit(1); } else { printf("String2 = %s\n", string2); printf("INT8 value is = %d\n",l); } printf("\nConverting third INT8 to long\n");
/* Note that the decimal places will be truncated. */
if (x= ifx_int8tolong(&num3, &l)) { printf("\tError %d in converting INT8 to long\n", x); exit(1); } else { printf("String3 = %s\n", string3); printf("INT8 value is = %d\n",l); } printf("\nIFX_INT8tOLONG Sample Program over.\n\n"); exit(0); } 输出