octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #34037] sscanf pads with null when reading in


From: Ben Barrowes
Subject: [Octave-bug-tracker] [bug #34037] sscanf pads with null when reading in %#c from a string
Date: Wed, 17 Aug 2011 18:28:39 +0000
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0

URL:
  <http://savannah.gnu.org/bugs/?34037>

                 Summary: sscanf pads with null when reading in %#c from a
string
                 Project: GNU Octave
            Submitted by: barrowes
            Submitted on: Wed 17 Aug 2011 06:28:38 PM GMT
                Category: Interpreter
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Matlab Compatibility
                  Status: None
             Assigned to: None
         Originator Name: Ben Barrowes
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: dev
        Operating System: GNU/Linux

    _______________________________________________________

Details:

sscanf (and possible fscanf?) pad a character array with nulls when reading a
string with a %#c format specifier. Matlab does not pad with nulls.

This can cause problems when determining the length of a string after sscanf.

In octave:

octave:3> aa=sscanf('123456','%10c')
aa = 123456
octave:4> length(aa)
ans =  10
octave:5> double(aa)
ans =

   49   50   51   52   53   54    0    0    0    0

octave:6> 







While in matlab:

>> aa=sscanf('123456','%10c')
aa =
123456
>> length(aa)
ans =
     6
>> double(aa)
ans =
    49    50    51    52    53    54
>>  






    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?34037>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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