 |
INFORMIX-ESQL/C Programmer's Manual ESQL/C Function Library |
|
rstol()
The rstol() function converts a null-terminated string into a long integer value.
Syntax
Usage
The legal range of values is from -2,147,483,647 to 2,147,483,647. The value -2,147,483,648 is not valid because this value is a reserved value that indicates null.
Return Codes
Example
This sample program is in the rstol.ec file in the demo directory.
/*
* rstol.ec *
The following program tries to convert three strings to longs. It
displays the result of each attempt.
*/
#include <stdio.h>
EXEC SQL include sqltypes;
main()
{
mint err;
mlong l;
printf("RSTOL Sample ESQL Program running.\n\n");
l = 0;
printf("Converting String 'abc':\n");
if((err = rstol("abc", &l)) == 0)
printf("\tResult = %ld\n\n", l);
else
printf("\tError %d in conversion of string #1\n\n", err);
l = 0;
printf("Converting String '2147483646':\n");
if((err = rstol("2147483646", &l)) == 0)
printf("\tResult = %ld\n\n", l);
else
printf("\tError %d in conversion of string #2\n\n", err);
l = 0;
printf("Converting String '':\n");
if((err = rstol("", &l)) == 0)
{
if(risnull(CLONGTYPE, (char *) &l))
printf("\tResult = NULL\n\n", l);
else
printf("\tResult = %ld\n\n", l);
}
else
printf("\tError %d in conversion of string #3\n\n", err);
printf("\nRSTOL Sample Program over.\n\n");
}
Output
INFORMIX-ESQL/C Programmer's Manual, Version 9.21
Copyright © 1999, Informix Software, Inc. All rights reserved