⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c103_12.htm

📁 经典c语言教程
💻 HTM
字号:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>scanf() 函数</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
</head>

<body bgcolor="#ccefcc">

<blockquote>
  <p>scanf() 和 printf() 一样, 也有格式控制字符串和变换说明符。scanf() 
  函数的参数必须是指向变量的指针。在基本数据类型的变量前面, 
  必须用 <font color="#FF0000">&amp;</font>。但是, 
  字符数组名的前面不可以用 <font color="#FF0000">&amp;</font>。</p>
  <div align="center"><center><table border="0" width="333" bgcolor="#FF9933"
  cellspacing="3" cellpadding="0">
    <tr>
      <td width="333">scanf(格式控制字符串, 参数1, 参数2, ...)</td>
    </tr>
  </table>
  </center></div><p><br>
  </p>
  <div align="center"><center><table border="0" width="140" bgcolor="#FF9933"
  cellspacing="3" cellpadding="0">
    <tr>
      <td width="136">&amp; + 基本数据类型 <br>
      &nbsp; + 字符串变量</td>
    </tr>
  </table>
  </center></div><p><br>
  <br>
  例题: <br>
  scanf(&quot;%d %f&quot;,&amp;age,&amp;weight);<br>
  printf(&quot;ag:%d,wh:%f&quot;,age,weight);<br>
  ......<br>
  如果你已键入了 16,45.6 <br>
  那么看一下屏幕的输出是:<br>
  ag:16 wh:45.600000</p>
  <p>例如: <br>
  char name[20]<br>
  scanf(&quot;%s&quot;,name); <br>
  printf(&quot;my name is %s\n&quot;,name);<br>
  如果输入过 mary<br>
  那么看一下屏幕的输出是:<br>
  my name is mary<br>
  </p>
  <p>在这个练习中, 我们用到过函数 scanf() 和 printf()!</p>
</blockquote>

<p align="center"><a href="javascript:close()">关闭</a></p>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -