Home
Highly Reusable Software By activity User Interface Text Strings Math Processing
Stored Data
Communications
Hard World File System
|
#License - #Source code - #Example Use -
#include <librock/parse.h> int librock_ssconsl( const char *strptr, int radix, long librock_PTR *plRet ); int librock_sscons( const char *sptr, int radix, int *piRet ); int librock_ssdec( const char *sptr, int *piRet );
Skip leading ' ' or '\t', accept an optional '-', then convert to an int or long int in the specified radix (base.)
Stores conversion result indirectly (at pRet, if not NULL), and returns the number of characters processed.
Radix can be up to 36. A-Z are taken in upper or lower case for digits after 0-9.
When radix == 0, takes prefix from the string
prefix - radix 0 - octal 0x - hex 0b - binary default - decimal Processing stops at the first character not a valid digit in the radix. Returns number of characters processed or 0 if could not process any characters. If 0 is returned, the value at *pRet is unchanged. Typical use is to replace atol(), to gain the additional radix conversions or to determine that characters were processed. #ifdef librock_TYPICAL_USE_sscons const char *ptr = "07 0x08 0b1001 10 Q 11"; while(1) { int val; int cnt = librock_sscons(ptr,0,&val); if (!cnt) { break; } printf("%d\n",val); ptr += cnt; while (*ptr == ' ') { ptr++; } } #endif
// [No external calls]
Copyright 1998-2002 Forrest J. Cavalier III, http://www.mibsoftware.com Licensed under BSD-ish license, NO WARRANTY. Copies must retain this block. License text in <librock/license/librock.txt> librock_LIDESC_HC=12440211096131f5976d36be0cddca4cd9152e45
librock_sscons passed tests in tss (Unix/Linux/BSD: 2002/08/08 sys=FreeBSD using gcc)
librock_sscons passed tests in tss (WIN32: 2002/08/08 sys=NT 4.0 using MSVC)
librock_ssconsl passed tests in tss (Unix/Linux/BSD: 2002/08/08 sys=FreeBSD using gcc)
librock_ssconsl passed tests in tss (WIN32: 2002/08/08 sys=NT 4.0 using MSVC)
librock_ssdec passed tests in tss (Unix/Linux/BSD: 2002/08/08 sys=FreeBSD using gcc)
librock_ssdec passed tests in tss (WIN32: 2002/08/08 sys=NT 4.0 using MSVC)
Verbatim copying and distribution of this generated page is permitted in any medium provided that no changes are made.
(The source of this manual page may be covered by a more permissive license which allows modifications.)
Want to help? We welcome comments, patches. -- Need help? Request paid support.