help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*printf Understanding


From: John W. Eaton
Subject: *printf Understanding
Date: Tue, 7 Mar 2006 12:03:49 -0500

On  7-Mar-2006, Bill Denney wrote:

| I have an application where I want to output a file with indenting (the 
| XML I was mentioning earlier).  I thought that I would just use the %*s 
| feature to output a string that is the size of my indentation, but I found 
| that code like
| 
| sprintf('%*s', 0, ' ')
| 
| returns a single space instead of an empty string as I expected.
| 
| Is that the way it's supposed to work?

Yes, I think it is, as I think field widths are always minimums.  You
are printing " ", so that will always have a width of at least 1
character.

Try

  sprintf('%*s', 0, '')

instead.

jwe



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]