<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Standard C String & Character</title>
</head>
<body>
<div class="Section1" style="LAYOUT-GRID: 15.6pt none">
<table style="BACKGROUND: #eeeeff; WIDTH: 100%; mso-cellspacing: 1.5pt; mso-padding-alt: 0cm 0cm 0cm 0cm" cellPadding="0" width="100%" bgColor="#eeeeff" border="0">
<tbody>
<tr>
<td style="PADDING-RIGHT: 0.75pt; PADDING-LEFT: 0.75pt; PADDING-BOTTOM: 0.75pt; PADDING-TOP: 0.75pt">
<p class="MsoNormal"><span lang="EN-US"><a href="file:///C:/Documents%20and%20Settings/ZS/桌面/index.html">cppreference.com</a>
-> <a href="file:///C:/Documents%20and%20Settings/ZS/桌面/stdstring.html">Standard
C String & Character</a> -> </span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">详解</span><span lang="EN-US" style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体"><o:p>
</o:p>
</span></p>
</td>
</tr>
</tbody>
</table>
<h1>标准<span lang="EN-US">c字符和字符串</span></h1>
<div class="MsoNormal" style="TEXT-ALIGN: center" align="center">
<span lang="EN-US">
<hr align="center" width="100%" SIZE="2">
</span>
</div>
<h2><span lang="EN-US"><a name="atof">atof</a></span></h2>
<p class="MsoNormal"><i><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">语法</span><span lang="EN-US">:</span></i></p>
<table style="BACKGROUND: #ccccff; mso-cellspacing: 1.5pt; mso-padding-alt: 0cm 0cm 0cm 0cm" cellPadding="0" bgColor="#ccccff" border="0">
<tbody>
<tr>
<td style="PADDING-RIGHT: 0.75pt; PADDING-LEFT: 0.75pt; PADDING-BOTTOM: 0.75pt; PADDING-TOP: 0.75pt">
<pre><span lang="EN-US"> <o:p>
</o:p>
</span></pre>
<pre><span lang="EN-US"><span style="mso-spacerun: yes"> </span>#include <stdlib.h></span></pre>
<pre><span lang="EN-US"><span style="mso-spacerun: yes"> </span>double atof( const char *str );</span></pre>
</td>
</tr>
</tbody>
</table>
<p>功能<span lang="EN-US">:将字符串<i>str</i>转换成一个双精度数值并返回结果。
参数<i>str</i> 必须以有效数字开头,但是允许以“E”或“e”除外的任意非数字字符结尾。例如:</span></p>
<pre><span lang="EN-US"><span style="mso-spacerun: yes"> </span>x = atof( "42.0is_the_answer" );</span></pre>
<p style="tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span lang="EN-US">x的值为42.0.</span></p>
<p class="MsoNormal" style="tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><i><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">相关主题</span><span lang="EN-US">:</span></i><span lang="EN-US"><br>
<strong><a href="#atoi">atoi()</a> and <a href="#atol">atol()</a>.</strong></span></p>
<div class="MsoNormal" style="TEXT-ALIGN: center; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" align="center">
<span lang="EN-US">
<hr align="center" width="100%" SIZE="2">
</span>
</div>
<h2 style="tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span lang="EN-US">
<a name="atoi">atoi</a></span></h2>
<p class="MsoNormal" style="tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><i><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">语法</span><span lang="EN-US">:</span></i></p>
<table style="BACKGROUND: #ccccff; mso-cellspacing: 1.5pt; mso-padding-alt: 0cm 0cm 0cm 0cm" cellPadding="0" bgColor="#ccccff" border="0">
<tbody>
<tr>
<td style="PADDING-RIGHT: 0.75pt; PADDING-LEFT: 0.75pt; PADDING-BOTTOM: 0.75pt; PADDING-TOP: 0.75pt">
<pre><span lang="EN-US"> <o:p>
</o:p>
</span></pre>
<pre><span lang="EN-US"><span style="mso-spacerun: yes"> </span>#include <stdlib.h></span></pre>
<pre><span lang="EN-US"><span style="mso-spacerun: yes"> </span>int atoi( const char *str );</span></pre>
</td>
</tr>
</tbody>
</table>
<p style="tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt">功能:将字符串<i><span lang="EN-US">str</span></i>转换成一个整数并返回结果。参数<i><span lang="EN-US">str</span></i><span lang="EN-US">
以数字开头,当函数从<i>str</i>
中读到非数字字符则结束转换并将结果返回。例如,</span></p>
<pre><span lang="EN-US"><span style="mso-spacerun: yes"> </span>i = atoi( "512.035" );</span></pre>
<p style="tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span lang="EN-US">i
的值为 512.</span></p>
<p class="MsoNormal" style="tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><i><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">相关主题</span><span lang="EN-US">:</span></i><span lang="EN-US"><br>
<strong><a href="#atof">atof()</a> and <a href="#atol">atol()</a>.</strong></span></p>
<div class="MsoNormal" style="TEXT-ALIGN: center; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" align="center">
<span lang="EN-US">
<hr align="center" width="100%" SIZE="2">
</span>
</div>
<h2 style="tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><span lang="EN-US">
<a name="atol">atol</a></span></h2>
<p class="MsoNormal" style="tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"><i><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">语法</span><span lang="EN-US">:</span></i></p>
<table style="BACKGROUND: #ccccff; mso-cellspacing: 1.5pt; mso-padding-alt: 0cm 0cm 0cm 0cm" cellPadding="0" bgColor="#ccccff" border="0">
<tbody>
<tr>
<td style="PADDING-RIGHT: 0.75pt; PADDING-LEFT: 0.75pt; PADDING-BOTTOM: 0.75pt; PADDING-TOP: 0.75pt">
<pre><span lang="EN-US"> <o:p>
</o:p>
</span></pre>
<pre><span lang="EN-US"> <span style="mso-spacerun: yes"> </span>#include <stdlib.h></span></pre>
<pre><span lang="EN-US"><span style="mso-spacerun: yes"> </span>long atol( const char *str );</span></pre>
</td>
</tr>
</tbody>
</table>
<p style="tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt">功能:将字符串转换成长整型数并返回结果。函数会扫描参数<i><span lang="EN-US">str</span></i>字符串,跳过前面的空格字符,直到遇上数字或正负符号才开始做转换,而再遇到非数字或字符串结束时才结束转换,并将结果返回。例如,</p>
<pre><span lang="EN-US"><span style="mso-spacerun: yes"> </span>x = atol( "1024.0001" );</span></pre>
<p style="tab-stops: 45.8pt 91.6pt 1
评论0
最新资源