Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > b38d2da330d1936e5ab1307c039c4941 > files > 311

octave-doc-3.6.4-3.mga4.noarch.rpm

<html lang="en">
<head>
<title>Input Conversion Syntax - GNU Octave</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="GNU Octave">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="C_002dStyle-I_002fO-Functions.html#C_002dStyle-I_002fO-Functions" title="C-Style I/O Functions">
<link rel="prev" href="Formatted-Input.html#Formatted-Input" title="Formatted Input">
<link rel="next" href="Table-of-Input-Conversions.html#Table-of-Input-Conversions" title="Table of Input Conversions">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc    { font-variant:small-caps }
  span.roman { font-family:serif; font-weight:normal; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
--></style>
</head>
<body>
<div class="node">
<a name="Input-Conversion-Syntax"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Table-of-Input-Conversions.html#Table-of-Input-Conversions">Table of Input Conversions</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Formatted-Input.html#Formatted-Input">Formatted Input</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="C_002dStyle-I_002fO-Functions.html#C_002dStyle-I_002fO-Functions">C-Style I/O Functions</a>
<hr>
</div>

<h4 class="subsection">14.2.12 Input Conversion Syntax</h4>

<p>A <code>scanf</code> template string is a string that contains ordinary
multibyte characters interspersed with conversion specifications that
start with &lsquo;<samp><span class="samp">%</span></samp>&rsquo;.

   <p>Any whitespace character in the template causes any number of whitespace
characters in the input stream to be read and discarded.  The whitespace
characters that are matched need not be exactly the same whitespace
characters that appear in the template string.  For example, write
&lsquo;<samp><span class="samp"> , </span></samp>&rsquo; in the template to recognize a comma with optional whitespace
before and after.

   <p>Other characters in the template string that are not part of conversion
specifications must match characters in the input stream exactly; if
this is not the case, a matching failure occurs.

   <p>The conversion specifications in a <code>scanf</code> template string
have the general form:

<pre class="example">     % <var>flags</var> <var>width</var> <var>type</var> <var>conversion</var>
</pre>
   <p>In more detail, an input conversion specification consists of an initial
&lsquo;<samp><span class="samp">%</span></samp>&rsquo; character followed in sequence by:

     <ul>
<li>An optional <dfn>flag character</dfn> &lsquo;<samp><span class="samp">*</span></samp>&rsquo;, which says to ignore the text
read for this specification.  When <code>scanf</code> finds a conversion
specification that uses this flag, it reads input as directed by the
rest of the conversion specification, but it discards this input, does
not return any value, and does not increment the count of
successful assignments. 
<a name="index-flag-character-_0028_0040code_007bscanf_007d_0029-1004"></a>
<li>An optional decimal integer that specifies the <dfn>maximum field
width</dfn>.  Reading of characters from the input stream stops either when
this maximum is reached or when a non-matching character is found,
whichever happens first.  Most conversions discard initial whitespace
characters, and these discarded characters don't count towards the
maximum field width.  Conversions that do not discard initial whitespace
are explicitly documented. 
<a name="index-maximum-field-width-_0028_0040code_007bscanf_007d_0029-1005"></a>
<li>An optional type modifier character.  This character is ignored by
Octave's <code>scanf</code> function, but is recognized to provide
compatibility with the C language <code>scanf</code>.

     <li>A character that specifies the conversion to be applied. 
</ul>

   <p>The exact options that are permitted and how they are interpreted vary
between the different conversion specifiers.  See the descriptions of the
individual conversions for information about the particular options that
they allow.

   </body></html>