[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sscanf
From: |
Ben Abbott |
Subject: |
Re: sscanf |
Date: |
Fri, 16 Nov 2012 17:37:54 -0500 |
On Nov 16, 2012, at 4:26 PM, Dimitri Maziuk wrote:
>
> Can anyone explain why, given the input string
>
> 1 M HE 2.140
>
> [row, cnt, err] = sscanf( "%4d %1s %4s %8.3f", str )
> row
>
> fails with "error: sscanf: invalid format specified"
>
> whereas
>
> [row, cnt, err] = sscanf( "%d %s %s %f", str )
> row
>
> prints
>
> row =
>
> 1.0000
> 77.0000
> 72.0000
> 69.0000
> 2.1400
> ...
>
> (and yes, I know what 77, 72, and 69 are, that's not the question)
>
> TIA
The problem appears to be with the float.
[row, cnt, err] = sscanf (str, "%4d %1s %4s %8f")
row =
1.0000
77.0000
72.0000
69.0000
2.1400
cnt = 4
err =
Ben
- sscanf, Dimitri Maziuk, 2012/11/16
- Re: sscanf,
Ben Abbott <=
- Re: sscanf, Ben Abbott, 2012/11/16