Aztec C cource - stoi.c

dcn at ihuxl.UUCP dcn at ihuxl.UUCP
Sat Nov 12 08:31:32 AEST 1983


/* stoi - convert string to integer (checks sign) */

#include "stdio.h"

stoi(s)
char *s ;
{
	int n, sign ;

	while( *s == BLANK || *s == NL || *s == TAB )
		s++ ;

	sign = 1 ;
	if( *s == '+' )
		s++ ;
	else if( *s == '-' ) {
		sign = -1 ;
		s++ ;
	}
	for( n=0 ; *s >= '0' && *s <= '9' ; s++ )
		n = 10 * n + *s - '0' ;
	return( sign * n ) ;
}



More information about the Comp.sources.unix mailing list