📄 atoi.c
字号:
/*************************************************************************
*
* Copyright Mentor Graphics Corporation 2002
* All Rights Reserved.
*
* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS
* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS
* SUBJECT TO LICENSE TERMS.
*
*************************************************************************/
/*************************************************************************
* FILE NAME VERSION
*
* atoi.c Nucleus Common Library 1.1
*
* DESCRIPTION
*
* This file contains the implementation of NCL_atoi.
*
* DATA STRUCTURES
*
* None.
*
* FUNCTIONS
*
* NCL_atoi
*
* DEPENDENCIES
*
* ncl.h
* stdlib.h
* ctype.h
* convert.h
* nucleus.h
*
************************************************************************/
#define NU_NCL_SOURCE_FILE
#include "ncl\inc\ncl.h"
#include "ncl\inc\stdlib.h"
#include "ncl\inc\ctype.h"
#include "ncl\inc\convert.h"
#include "plus\nucleus.h" /* MMU Support */
/*************************************************************************
*
* FUNCTION
*
* NCL_atoi
*
* DESCRIPTION
*
* Converts string of ASCII chars to an integer.
*
* INPUTS
*
* nptr Null-terminated string to be converted.
*
* OUTPUTS
*
* int Value the string represented.
*
*************************************************************************/
int NCL_atoi (const char *nptr)
{
register const uchar *ptr = (const uchar *)nptr;
register uint num = 0;
register int c = *ptr;
register int neg = 0;
while (NCL_isspace(c))
c = *++ptr; /* skip over whitespace chars */
if (c == '-') /* get an optional sign */
{
neg = 1;
c = *++ptr;
}
else
if (c == '+')
c = *++ptr;
while (NCL_isdigit(c))
{
num = (10 * num) + (c - '0');
c = *++ptr;
}
if (neg)
{
return (SINEGATE(num));
}
return ((int) num);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -