View mode: basic / threaded / horizontal-split · Log in · Help
July 03, 2002
wsprintf with floats
How do I use wsprintf with a float? I tried %f but it just printed f

If i use %i it cuts off the decimal...

Steve De Chellis
July 03, 2002
Re: wsprintf with floats
%g for floats, %d for integers. -Walter

"Steve & Denise De Chellis" <dbouton@snet.net> wrote in message
news:afvcvu$26q7$1@digitaldaemon.com...
> How do I use wsprintf with a float? I tried %f but it just printed f
>
> If i use %i it cuts off the decimal...
>
> Steve De Chellis
>
>
July 04, 2002
Re: wsprintf with floats
wsprintf (szBuffer, TEXT ("c %g "), fEncumb);
         SetDlgItemText (hDlg, 28, szBuffer);

That is the code I tried but in the Dialog I end up with "c g"

Steve


"Walter" <walter@digitalmars.com> wrote in message
news:afvo5v$2hge$1@digitaldaemon.com...
> %g for floats, %d for integers. -Walter
>
> "Steve & Denise De Chellis" <dbouton@snet.net> wrote in message
> news:afvcvu$26q7$1@digitaldaemon.com...
> > How do I use wsprintf with a float? I tried %f but it just printed f
> >
> > If i use %i it cuts off the decimal...
> >
> > Steve De Chellis
> >
> >
>
>
July 04, 2002
Re: wsprintf with floats
Changing it to sprintf did work though....

Anyone know why?

Steve De Chellis

"Steve & Denise De Chellis" <dbouton@snet.net> wrote in message
news:ag0auc$25p$1@digitaldaemon.com...
>           wsprintf (szBuffer, TEXT ("c %g "), fEncumb);
>           SetDlgItemText (hDlg, 28, szBuffer);
>
> That is the code I tried but in the Dialog I end up with "c g"
>
> Steve
>
>
> "Walter" <walter@digitalmars.com> wrote in message
> news:afvo5v$2hge$1@digitaldaemon.com...
> > %g for floats, %d for integers. -Walter
> >
> > "Steve & Denise De Chellis" <dbouton@snet.net> wrote in message
> > news:afvcvu$26q7$1@digitaldaemon.com...
> > > How do I use wsprintf with a float? I tried %f but it just printed f
> > >
> > > If i use %i it cuts off the decimal...
> > >
> > > Steve De Chellis
> > >
> > >
> >
> >
>
>
July 04, 2002
Re: wsprintf with floats
Try replacing TEXT("c %g") with L"c %g".

"Steve & Denise De Chellis" <dbouton@snet.net> wrote in message
news:ag0isj$aq9$1@digitaldaemon.com...
> Changing it to sprintf did work though....
>
> Anyone know why?
>
> Steve De Chellis
>
> "Steve & Denise De Chellis" <dbouton@snet.net> wrote in message
> news:ag0auc$25p$1@digitaldaemon.com...
> >           wsprintf (szBuffer, TEXT ("c %g "), fEncumb);
> >           SetDlgItemText (hDlg, 28, szBuffer);
> >
> > That is the code I tried but in the Dialog I end up with "c g"
> >
> > Steve
> >
> >
> > "Walter" <walter@digitalmars.com> wrote in message
> > news:afvo5v$2hge$1@digitaldaemon.com...
> > > %g for floats, %d for integers. -Walter
> > >
> > > "Steve & Denise De Chellis" <dbouton@snet.net> wrote in message
> > > news:afvcvu$26q7$1@digitaldaemon.com...
> > > > How do I use wsprintf with a float? I tried %f but it just printed f
> > > >
> > > > If i use %i it cuts off the decimal...
> > > >
> > > > Steve De Chellis
> > > >
> > > >
> > >
> > >
> >
> >
>
>
July 04, 2002
Re: wsprintf with floats
Guys

Maybe I've missed something all these years, but I never thought that
wsprintf handled floating point. The help for wsprintf certainly does not
mention any floating point format sequences.

Matthew

"Walter" <walter@digitalmars.com> wrote in message
news:ag0k94$bu6$1@digitaldaemon.com...
> Try replacing TEXT("c %g") with L"c %g".
>
> "Steve & Denise De Chellis" <dbouton@snet.net> wrote in message
> news:ag0isj$aq9$1@digitaldaemon.com...
> > Changing it to sprintf did work though....
> >
> > Anyone know why?
> >
> > Steve De Chellis
> >
> > "Steve & Denise De Chellis" <dbouton@snet.net> wrote in message
> > news:ag0auc$25p$1@digitaldaemon.com...
> > >           wsprintf (szBuffer, TEXT ("c %g "), fEncumb);
> > >           SetDlgItemText (hDlg, 28, szBuffer);
> > >
> > > That is the code I tried but in the Dialog I end up with "c g"
> > >
> > > Steve
> > >
> > >
> > > "Walter" <walter@digitalmars.com> wrote in message
> > > news:afvo5v$2hge$1@digitaldaemon.com...
> > > > %g for floats, %d for integers. -Walter
> > > >
> > > > "Steve & Denise De Chellis" <dbouton@snet.net> wrote in message
> > > > news:afvcvu$26q7$1@digitaldaemon.com...
> > > > > How do I use wsprintf with a float? I tried %f but it just printed
f
> > > > >
> > > > > If i use %i it cuts off the decimal...
> > > > >
> > > > > Steve De Chellis
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
July 04, 2002
Re: wsprintf with floats
It should work just like sprintf, but for wchar's.

"Matthew Wilson" <matthew@thedjournal.com> wrote in message
news:ag0lbp$d39$1@digitaldaemon.com...
> Guys
>
> Maybe I've missed something all these years, but I never thought that
> wsprintf handled floating point. The help for wsprintf certainly does not
> mention any floating point format sequences.
>
> Matthew
July 05, 2002
Re: wsprintf with floats
Walter,

No offense, but I think you're getting mixed up with swprintf - the wide
version of sprintf - which is an ANSI function. Steve is talking (as am I)
about wsprintf - the USER32 sprintf replacement (apart from floating
points) - which is a shorthand for all those people (wise souls, at least
when using MSVC) who do not wish to link to the C-runtime libaries. Neither
the ANSI (wsprintfA) or Unicode (wsprintfW) versions use floating points,
I'm afraid

Matthew

"Walter" <walter@digitalmars.com> wrote in message
news:ag0vqq$o8r$1@digitaldaemon.com...
> It should work just like sprintf, but for wchar's.
>
> "Matthew Wilson" <matthew@thedjournal.com> wrote in message
> news:ag0lbp$d39$1@digitaldaemon.com...
> > Guys
> >
> > Maybe I've missed something all these years, but I never thought that
> > wsprintf handled floating point. The help for wsprintf certainly does
not
> > mention any floating point format sequences.
> >
> > Matthew
>
>
>
July 05, 2002
Re: wsprintf with floats
Oh, I think you're right. My goof! I always have to stop and think if it's
sw or ws. Argh.

"Matthew Wilson" <matthew@thedjournal.com> wrote in message
news:ag3g4m$5dc$1@digitaldaemon.com...
> Walter,
>
> No offense, but I think you're getting mixed up with swprintf - the wide
> version of sprintf - which is an ANSI function. Steve is talking (as am I)
> about wsprintf - the USER32 sprintf replacement (apart from floating
> points) - which is a shorthand for all those people (wise souls, at least
> when using MSVC) who do not wish to link to the C-runtime libaries.
Neither
> the ANSI (wsprintfA) or Unicode (wsprintfW) versions use floating points,
> I'm afraid
>
> Matthew
July 10, 2002
Re: wsprintf with floats
No worries. I guess I'm more attuned only because I chronically spend so
much effort in avoiding M$'s C-runtime library ...

"Walter" <walter@digitalmars.com> wrote in message
news:ag4kcs$1bdq$2@digitaldaemon.com...
> Oh, I think you're right. My goof! I always have to stop and think if it's
> sw or ws. Argh.
>
> "Matthew Wilson" <matthew@thedjournal.com> wrote in message
> news:ag3g4m$5dc$1@digitaldaemon.com...
> > Walter,
> >
> > No offense, but I think you're getting mixed up with swprintf - the wide
> > version of sprintf - which is an ANSI function. Steve is talking (as am
I)
> > about wsprintf - the USER32 sprintf replacement (apart from floating
> > points) - which is a shorthand for all those people (wise souls, at
least
> > when using MSVC) who do not wish to link to the C-runtime libaries.
> Neither
> > the ANSI (wsprintfA) or Unicode (wsprintfW) versions use floating
points,
> > I'm afraid
> >
> > Matthew
>
>
>
« First   ‹ Prev
1 2
Top | Discussion index | About this forum | D home