1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
<html>
<head>
<title>EAGLE Help: strsplit()</title>
</head>
<body bgcolor=white>
<font face=Helvetica,Arial>
<hr>
<i>EAGLE Help</i>
<h1><center>strsplit()</center></h1>
<hr>
<dl>
<dt>
<b>Function</b>
<dd>
Splits a string into separate fields.
<p>
<dt>
<b>Syntax</b>
<dd>
<tt>int strsplit(string &array[], string s, char separator);</tt>
<p>
<dt>
<b>Returns</b>
<dd>
The <tt>strsplit</tt> function returns the number of entries copied into <tt>array</tt>.
<p>
<dt>
<b>Description</b>
<dd>
<tt>strsplit</tt> splits the string <tt>s</tt> at the given <tt>separator</tt>
and stores the resulting fields in the <tt>array</tt>.
<p>
If <tt>separator</tt> is the newline character (<tt>"\n"</tt>) the last field
will be silently dropped if it is empty. This is done to have a text file that
consists of N lines (each of which is terminated with a newline) and is read
in with the <a href=240.htm>fileread()</a> function to be split into
an array of N strings. With any other <tt>separator</tt> an empty field at the
end of the string will count, so <tt>"a:b:c:"</tt> will result in 4 fields,
the last of which is empty.
<p>
</dl>
<b>See also</b> <a href=259.htm>strjoin</a>,
<a href=249.htm>lookup</a>,
<a href=240.htm>fileread</a>
<p>
<b>Example</b>
<pre>
string a[];
int n = strsplit(a, "Field 1:Field 2:Field 3", ':');
</pre>
<hr>
<table width=100% cellspacing=0 border=0><tr><td align=left><font face=Helvetica,Arial>
<a href=index.htm>Index</a>
</font></td><td align=right><font face=Helvetica,Arial size=-1>
<i>Copyright © 2005 CadSoft Computer GmbH</i>
</font></td></tr></table>
<hr>
</font>
</body>
</html>
|