[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions , Volume 2


wstrtol, watol, or watoi Subroutine

Purpose

Converts a string to an integer.

Library

Standard C Library (libc.a)

Syntax

#include <wstring.h>


long wstrtol ( String, Pointer, Base)
wchar_t *String, **Pointer;
int Base;

long watol (String)
wchar_t *String;

int watoi (String)
wchar_t *String;

Description

The wstrtol subroutine returns a long integer that is converted from the string pointed to by the String parameter. The string is searched until a character is found that is inconsistent with Base. Leading white-space characters defined by the ctype subroutine iswspace are ignored.

When the value of Pointer is not (wchar_t **) null, a pointer to the terminating character is returned to the address indicated by Pointer. When an integer cannot be created, the address indicated by Pointer is set to String, and 0 is returned.

When the value of Base is positive and not greater than 36, that value is used as the base during conversion. Leading zeros that follow an optional leading sign are ignored. When the value of Base is 16, 0x and 0X are ignored.

When the value of Base is 0, the system chooses an appropriate base after examining the actual string. An optional sign followed by a leading zero signifies octal, and a leading 0x or 0X signifies hexadecimal. In all other cases, the subroutines assume a decimal base.

Truncation from long data type to int data type occurs by assignment, and also by explicit casting.

The watol (String) subroutine functions like wstrtol (String, (wchar_t **) null, 10).

The watoi (String) subroutine functions like (int) wstrtol (String, (wchar_t **) null, 10).

Note: Even if overflow occurs, it is ignored.

Parameters


String Specifies the address of the string to scan.
Pointer Specifies the address at which the pointer to the terminating character is stored.
Base Specifies an integer value used as the base during conversion.

Implementation Specifics

These subroutines are part of Base Operating System (BOS) Runtime.

Related Information

The atof, atoff, strtod, strtof subroutine, scanf, fscanf, sscanf (scanf, fscanf, sscanf, or wsscanf Subroutine) subroutine, strtol, strtoul, atol, atoi (strtol, strtoul, strtoll, strtoull, atol, or atoi Subroutine) subroutine, wstrtod, watof (wstrtod or watof Subroutine) subroutine.

Subroutines Overview in AIX 5L Version 5.1 General Programming Concepts: Writing and Debugging Programs.


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]