LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

sscanf question

I keep getting errors (unknown specifier) on following code, using CVI7.0:

sscanf(temp_str, "%lg%*t", r64Result);

temp_str has numerical values. I don't know what the above format
specifier in sscanf means. Can anyone help. This is all over the driver
code that I inherited.



vishi
0 Kudos
Message 1 of 4
(3,643 Views)
I hope 'r64result' is a pointer to a double, since that is what is required here.

%lg means "scan a real number and put it in a double"

%*t doesn't mean anything, as far as I am aware, as 't' isn't a valid conversion specifier in ANSI C. Well, not the ANSI C I know anyway.

A long time ago, NI included an ANSI C reference manual with the CVI document set. Those were the days!

--
Martin.
--
Martin
Certified CVI Developer
0 Kudos
Message 2 of 4
(3,643 Views)
I don't have your final answer, but here's a little more breakdown on the format string in your statement.
%lg
g = floating point in e format (e.g. 5.4321E+03) or f format (e.g. 5432.1).
l = long (or double for a floating point number).
So %lg = double.
%*t
* = skip this field.
t = ??? unknown specifier (at least to me and CVI).
I couldn't find any documentation for a t format specifier. Since the * says to skip the field anyway, it seems safe to me to delete that term and to leave your format string "%lg".
Remember that sscanf (like other flavors of scanf) is looking for a pointer to the variable to be filled. Verify that the declaration for r64Result creates a pointer:
double *r64Result;
If the declaration is
double r64Result;
any other uses expect r64Resu
lt to hold a double, change the sscanf statement to
sscanf(temp_str, "%lg", &r64Result);
What tools were originally used to create your driver?
0 Kudos
Message 3 of 4
(3,643 Views)
Thanks guys. I knew about %lg, but have never seen "%*t". Oh well I
changed the code to use only "%lg" and it works.


vishi

Al S wrote:
> I don't have your final answer, but here's a little more breakdown on
> the format string in your statement.
> %lg
> g = floating point in e format (e.g. 5.4321E+03) or f format (e.g.
> 5432.1).
> l = long (or double for a floating point number).
> So %lg = double.
> %*t
> * = skip this field.
> t = ??? unknown specifier (at least to me and CVI).
> I couldn't find any documentation for a t format specifier. Since the
> * says to skip the field anyway, it seems safe to me to delete that
> term and to leave your format string "%lg".
> Remember that sscanf (like other flavors of scanf) is looking for a
> pointer to the v
ariable to be filled. Verify that the declaration for
> r64Result creates a pointer:
> double *r64Result;
> If the declaration is
> double r64Result;
> any other uses expect r64Result to hold a double, change the sscanf
> statement to
> sscanf(temp_str, "%lg", &r64Result);
> What tools were originally used to create your driver?
0 Kudos
Message 4 of 4
(3,643 Views)