Mercurial > hg > octave-nkf
diff liboctave/str-vec.cc @ 2493:8ed4362aa0d6
[project @ 1996-11-11 02:35:04 by jwe]
author | jwe |
---|---|
date | Mon, 11 Nov 1996 02:39:26 +0000 |
parents | 1b57120c997b |
children | 8b262e771614 |
line wrap: on
line diff
--- a/liboctave/str-vec.cc +++ b/liboctave/str-vec.cc @@ -31,6 +31,32 @@ #include "oct-term.h" #include "str-vec.h" +// Create a string vector from a NULL terminated list of C strings. + +string_vector::string_vector (const char * const *s) + : Array<string> () +{ + int n = 0; + + while (*s++) + n++; + + resize (n); + + for (int i = 0; i < n; i++) + elem (i) = s[i]; +} + +// Create a string vector from up to N C strings. Assumes that N is +// nonnegative. + +string_vector::string_vector (const char * const *s, int n) + : Array<string> (n) +{ + for (int i = 0; i < n; i++) + elem (i) = s[i]; +} + // Format a list in neat columns. Mostly stolen from GNU ls. ostream&