public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: sscanf trouble
@ 2011-01-25 19:57 Jonathan Andrews
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Andrews @ 2011-01-25 19:57 UTC (permalink / raw)
  To: gcc-help

n Tue, 2011-01-25 at 11:18 -0700, Bill McEnaney wrote:
> Why not replace the "=" with another character before you call sscanf?
> 
> Cheers,
> Bill
> Jon wrote:
> 
> >

Thanks for the idea, this was finger trouble by myself.

I was corrupting one of my variables between the call to sscanf and the
first printf.

Cheers,
Jon


^ permalink raw reply	[flat|nested] 5+ messages in thread
* Re: sscanf trouble
@ 2011-01-25 18:18 Bill McEnaney
  0 siblings, 0 replies; 5+ messages in thread
From: Bill McEnaney @ 2011-01-25 18:18 UTC (permalink / raw)
  To: jon, gcc-help

Why not replace the "=" with another character before you call sscanf?

Cheers,
Bill
Jon wrote:

> Hi people.
> 
> Can anyone help with what should be a simple problem. I have some text
> in the following form. Its a temperature reading from a wireless sensor,
> the format is T<sensor number>=<float ish> <TAB><TAB><Two digit ascii
> checksum>
> 
> T1=18.0<TAB><TAB>XX\n\r
> 
> Some examples:
> 
>         T1=-11.5        EA
>         T1=24.0         9D
> 
> Im trying to convert this string into a sensor ID, a floating point
> reading and a checksum as 3 variables using sscanf
> 
> sscanf(line,"T%d=%f\t\t%X",&sensorid,&temperature,&checksum);
> 
> No amount of variations on a theme seem to give me an entire decode
> here, seems the equals seems to screw things up.  Anyone any ideas how I
> can make this work?
> 
> Thanks for any advice,
> Jon
> 
> 
> 
> 
> 

________________________________________________________________
Please visit a saintly hero:
http://www.jakemoore.org

^ permalink raw reply	[flat|nested] 5+ messages in thread
* sscanf trouble
@ 2011-01-25 11:08 Jonathan Andrews
  2011-01-25 12:18 ` Jonathan Wakely
  2011-01-25 12:21 ` Adam Stein
  0 siblings, 2 replies; 5+ messages in thread
From: Jonathan Andrews @ 2011-01-25 11:08 UTC (permalink / raw)
  To: gcc-help

Hi people.

Can anyone help with what should be a simple problem. I have some text
in the following form. Its a temperature reading from a wireless sensor,
the format is T<sensor number>=<float ish> <TAB><TAB><Two digit ascii
checksum>

T1=18.0<TAB><TAB>XX\n\r

Some examples:

        T1=-11.5        EA
        T1=24.0         9D

Im trying to convert this string into a sensor ID, a floating point
reading and a checksum as 3 variables using sscanf

sscanf(line,"T%d=%f\t\t%X",&sensorid,&temperature,&checksum);

No amount of variations on a theme seem to give me an entire decode
here, seems the equals seems to screw things up.  Anyone any ideas how I
can make this work?

Thanks for any advice,
Jon




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-01-25 19:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-25 19:57 sscanf trouble Jonathan Andrews
  -- strict thread matches above, loose matches on Subject: below --
2011-01-25 18:18 Bill McEnaney
2011-01-25 11:08 Jonathan Andrews
2011-01-25 12:18 ` Jonathan Wakely
2011-01-25 12:21 ` Adam Stein

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).