Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > alt.msdos.programmer > #8 > unrolled thread

C scanf()

Started byT. Ment <triflemenot@protocol.invalid>
First post2019-02-28 16:43 +0000
Last post2019-03-05 15:56 +0000
Articles 20 on this page of 69 — 10 participants

Back to article view | Back to alt.msdos.programmer


Contents

  C scanf() T. Ment <triflemenot@protocol.invalid> - 2019-02-28 16:43 +0000
    Re: C scanf() T. Ment <t.ment@protocol.invalid> - 2019-02-28 22:07 +0000
    Re: C scanf() "R.Wieser" <address@not.available> - 2019-03-01 10:10 +0100
      Re: C scanf() Steve Nickolas <usotsuki@buric.co> - 2019-03-01 08:22 -0500
        Re: C scanf() T. Ment <t.ment@protocol.invalid> - 2019-03-01 16:25 +0000
          Re: C scanf() "R.Wieser" <address@not.available> - 2019-03-01 17:39 +0100
            Re: C scanf() src153 <src153@protocol.invalid> - 2019-03-01 18:08 +0000
              Re: C scanf() src153 <src153@protocol.invalid> - 2019-03-01 18:22 +0000
              Re: C scanf() rridge@csclub.uwaterloo.ca (Ross Ridge) - 2019-03-01 19:04 +0000
                Re: C scanf() src153 <src153@protocol.invalid> - 2019-03-01 19:15 +0000
                  Re: C scanf() rridge@csclub.uwaterloo.ca (Ross Ridge) - 2019-03-01 19:20 +0000
                    Re: C scanf() src153 <src153@protocol.invalid> - 2019-03-01 19:31 +0000
                      Re: C scanf() rridge@csclub.uwaterloo.ca (Ross Ridge) - 2019-03-01 21:29 +0000
                        Re: C scanf() src153 <src153@protocol.invalid> - 2019-03-01 21:53 +0000
                          Re: C scanf() rridge@csclub.uwaterloo.ca (Ross Ridge) - 2019-03-01 22:20 +0000
                            Re: C scanf() src153 <src153@protocol.invalid> - 2019-03-01 22:48 +0000
                              Re: C scanf() rridge@csclub.uwaterloo.ca (Ross Ridge) - 2019-03-01 23:34 +0000
                                Re: C scanf() src153 <src153@protocol.invalid> - 2019-03-01 23:41 +0000
                                  Re: C scanf() rridge@csclub.uwaterloo.ca (Ross Ridge) - 2019-03-02 00:09 +0000
                                    Re: C scanf() src153 <src153@protocol.invalid> - 2019-03-02 00:14 +0000
                                      Re: C scanf() rridge@csclub.uwaterloo.ca (Ross Ridge) - 2019-03-02 00:19 +0000
                                        Re: C scanf() src153 <src153@protocol.invalid> - 2019-03-02 00:32 +0000
                                          Re: C scanf() rridge@csclub.uwaterloo.ca (Ross Ridge) - 2019-03-02 00:44 +0000
                                  Re: C scanf() "R.Wieser" <address@not.available> - 2019-03-02 09:55 +0100
                                    Re: C scanf() src153 <src153@protocol.invalid> - 2019-03-02 15:54 +0000
                                      Re: C scanf() "R.Wieser" <address@not.available> - 2019-03-02 19:43 +0100
                                        Re: C scanf() rridge@csclub.uwaterloo.ca (Ross Ridge) - 2019-03-02 18:58 +0000
                                          Re: C scanf() "R.Wieser" <address@not.available> - 2019-03-02 20:16 +0100
                                            Re: C scanf() "Kerr-Mudd,John" <notsaying@invalid.org> - 2019-03-03 08:08 +0000
                                              Re: C scanf() "R.Wieser" <address@not.available> - 2019-03-03 10:05 +0100
                                                Re: C scanf() src153 <src153@protocol.invalid> - 2019-03-03 14:56 +0000
                                        Re: C scanf() src153 <src153@protocol.invalid> - 2019-03-02 19:06 +0000
                                          Re: C scanf() Sjouke Burry <burrynulnulfour@ppllaanneett.nnll> - 2019-03-02 20:12 +0100
                                            Re: C scanf() src153 <src153@protocol.invalid> - 2019-03-02 19:23 +0000
                                              Re: C scanf() Sjouke Burry <burrynulnulfour@ppllaanneett.nnll> - 2019-03-02 21:39 +0100
                                                Re: C scanf() "Gene Buckle" <gene.buckle@bbs.retroarchive.org.remove-zcb-this> - 2019-03-05 08:53 -0800
                                                Re: C scanf() "Gene Buckle" <gene.buckle@bbs.retroarchive.org.remove-zcb-this> - 2019-03-05 08:53 -0800
                                                  Re: C scanf() src153 <src153@protocol.invalid> - 2019-03-05 17:45 +0000
                                                  Re: C scanf() "Kerr-Mudd,John" <notsaying@invalid.org> - 2019-03-05 19:59 +0000
                                          Re: C scanf() "R.Wieser" <address@not.available> - 2019-03-02 20:23 +0100
                                            Re: C scanf() src153 <src153@protocol.invalid> - 2019-03-02 19:53 +0000
                                              Re: C scanf() "R.Wieser" <address@not.available> - 2019-03-02 21:50 +0100
                                                Re: C scanf() src153 <src153@protocol.invalid> - 2019-03-02 21:19 +0000
                                                  Re: C scanf() "R.Wieser" <address@not.available> - 2019-03-02 22:46 +0100
                                                    Re: C scanf() src153 <src153@protocol.invalid> - 2019-03-02 22:09 +0000
                                      Re: C scanf() Rod Pemberton <invalid@lkntrgzxc.com> - 2019-03-02 17:05 -0500
                                        Re: C scanf() src153 <src153@protocol.invalid> - 2019-03-02 22:43 +0000
                                    Re: C scanf() Rod Pemberton <invalid@lkntrgzxc.com> - 2019-03-02 17:07 -0500
                                      Re: C scanf() "R.Wieser" <address@not.available> - 2019-03-03 07:44 +0100
                                        Re: C scanf() Rod Pemberton <invalid@lkntrgzxc.com> - 2019-03-03 02:20 -0500
                                          Re: C scanf() "R.Wieser" <address@not.available> - 2019-03-03 09:57 +0100
                                      Re: C scanf() Steve Nickolas <usotsuki@buric.co> - 2019-03-03 02:22 -0500
                              Re: C scanf() "R.Wieser" <address@not.available> - 2019-03-02 09:39 +0100
                      Re: C scanf() Rod Pemberton <invalid@lkntrgzxc.com> - 2019-03-01 16:58 -0500
                        Re: C scanf() src153 <src153@protocol.invalid> - 2019-03-01 22:39 +0000
                          Re: C scanf() Rod Pemberton <invalid@lkntrgzxc.com> - 2019-03-01 21:10 -0500
                        Re: C scanf() rridge@csclub.uwaterloo.ca (Ross Ridge) - 2019-03-01 22:46 +0000
                          Re: C scanf() src153 <src153@protocol.invalid> - 2019-03-01 22:55 +0000
              Re: C scanf() "R.Wieser" <address@not.available> - 2019-03-01 21:15 +0100
            Re: C scanf() Rod Pemberton <invalid@lkntrgzxc.com> - 2019-03-01 16:58 -0500
              Re: C scanf() T. Ment <t.ment@protocol.invalid> - 2019-03-01 22:30 +0000
              Re: C scanf() "R.Wieser" <address@not.available> - 2019-03-02 09:29 +0100
                Re: C scanf() src153 <src153@protocol.invalid> - 2019-03-02 16:10 +0000
                  Re: C scanf() "R.Wieser" <address@not.available> - 2019-03-02 19:54 +0100
                    Re: C scanf() src153 <src153@protocol.invalid> - 2019-03-02 19:12 +0000
              Re: C scanf() src153 <src153@protocol.invalid> - 2019-03-04 16:57 +0000
                Re: C scanf() src153 <src153@protocol.invalid> - 2019-03-04 18:59 +0000
                  Re: C scanf() Rod Pemberton <invalid@lkntrgzxc.com> - 2019-03-04 23:52 -0500
                    Re: C scanf() src153 <src153@protocol.invalid> - 2019-03-05 15:56 +0000

Page 1 of 4  [1] 2 3 4  Next page →


#8 — C scanf()

FromT. Ment <triflemenot@protocol.invalid>
Date2019-02-28 16:43 +0000
SubjectC scanf()
Message-ID<fv0g7eta1mngc8stdge4p3k87t1kpem32v@4ax.com>
This is a footnote to the pamo.c source code I posted earlier:

Some people think C scanf() is unsafe. The Borland C++ 3.1 help says:

> WARNING: scanf often leads to unexpected results if you diverge from an
> expected pattern. You must teach scanf how to synchronize at the end of a
> line.

But they don't show how to "synchronize at the end of a line," and leave
readers with the notion that scanf() is unsafe.

But it's a powerful tool when used carefully. The pamo.c source code can
"synchronize at the end of a line" to skip over annotations.

If you need to make an annotation that looks like patch data, any extra
non whitespace character on the same line as the patch data will convert
it to an annotation.

The pamo.c scanf() formats have the secret. May require some study.

[toc] | [next] | [standalone]


#9

FromT. Ment <t.ment@protocol.invalid>
Date2019-02-28 22:07 +0000
Message-ID<8vkg7eto94a9mh5deljief3p65cc3n4pbh@4ax.com>
In reply to#8
On Thu, 28 Feb 2019 16:43:20 +0000, T. Ment wrote:

> pamo.c source code can "synchronize at the end of a line"
> the c scanf() formats have the secret

One secret is understanding how scanf() treats newlines. You might think
it would "start over" after a newline.

But that's not how it works. A newline is not special, it's just another
whitespace to scanf().

Say you have five columns of numbers, and one line is missing a value,
having only four. After the fourth value, scanf() gobbles up the newline
as regular whitespace, taking its fifth value from the first one on the
next line. From then on, everything is out of sync.

To avoid such problems, you must devise "synchronized" format strings to
force scanf() to treat newlines specially, like pamo.c does.

[toc] | [prev] | [next] | [standalone]


#10

From"R.Wieser" <address@not.available>
Date2019-03-01 10:10 +0100
Message-ID<q5asup$s8b$1@gioia.aioe.org>
In reply to#8
T. Ment,

> Some people think C scanf() is unsafe. The Borland C++ 3.1 help says:
>
>> WARNING: scanf often leads to unexpected results if you diverge from
>> an expected pattern. You must teach scanf how to synchronize at the end
>>  of a line.
>
> But they don't show how to "synchronize at the end of a line," and leave
> readers with the notion that scanf() is unsafe.

You seem to have fallen into that "expected pattern" trap.  :-)

Just imagine its trying to match more than that the line is long.  Yep, it 
will ignore the line end and continue onto the next one - because it did not 
see the "but not further than the end of line" part yet.

Regards,
Rudy Wieser

[toc] | [prev] | [next] | [standalone]


#11

FromSteve Nickolas <usotsuki@buric.co>
Date2019-03-01 08:22 -0500
Message-ID<alpine.BSF.2.02.1903010822290.33351@frieza.hoshinet.org>
In reply to#10
My approach to using scanf()...Don't.  Use fgets() and sscanf().

-uso.

[toc] | [prev] | [next] | [standalone]


#12

FromT. Ment <t.ment@protocol.invalid>
Date2019-03-01 16:25 +0000
Message-ID<slki7ehmsas3padn33orensjs8io2cebo0@4ax.com>
In reply to#11
On Fri, 1 Mar 2019 08:22:55 -0500, Steve Nickolas <usotsuki@buric.co>
wrote:

>My approach to using scanf()...Don't.  Use fgets() and sscanf().

In the scanf() help, Borland C++ 3.1 has similar advice:


> The combination of gets or fgets followed by sscanf is safe and easy, and
> therefore recommended over scanf.

But like an old wives tale, it misinforms. There are safe ways to use
scanf().

With fgets() fixed buffer length, a long line with trailing whitespace
is a problem. You must either ignore it, or write special code to see if
there's something else out there besides whitespace.

With the right format string, scanf() does that automatically. It can be
done, I showed how.

I don't need to change your mind, I only want to present an alternate
view of scanf(). Even the technical elite have old wives tales. I don't
believe all of them.

[toc] | [prev] | [next] | [standalone]


#13

From"R.Wieser" <address@not.available>
Date2019-03-01 17:39 +0100
Message-ID<q5bn7f$q78$1@gioia.aioe.org>
In reply to#12
T. Ment,

> I only want to present an alternate view of scanf()

All you do is /claim/ that its possible, without offering anything to 
support it.   Whats stoping you ?

Regards,
Rudy Wieser

[toc] | [prev] | [next] | [standalone]


#14

Fromsrc153 <src153@protocol.invalid>
Date2019-03-01 18:08 +0000
Message-ID<avsi7e1413atfv7u1il6b77l32vudlb9dm@4ax.com>
In reply to#13
On Fri, 1 Mar 2019 17:39:01 +0100, "R.Wieser" <address@not.available>
wrote:

>> I only want to present an alternate view of scanf()

>All you do is /claim/ that its possible, without offering anything to 
>support it.

False statement.


> Whats stoping you ?

What stops Usenet trolls from reading. Who knows. Into the killfile you
go.


[toc] | [prev] | [next] | [standalone]


#15

Fromsrc153 <src153@protocol.invalid>
Date2019-03-01 18:22 +0000
Message-ID<jqti7et6v26srt8hbtbo132ngcrs0ve48q@4ax.com>
In reply to#14
>> All you do is /claim/

> What stops Usenet trolls from reading. Who knows. Into the killfile you
> go.

Oh wait, maybe that's too hard to understand. Let me help you:

/What/ /stops/ /Usenet/ /trolls/ /from/ /reading/

/Who/ /knows/

/Into/ /the/ /killfile/ /you/ /go/


[toc] | [prev] | [next] | [standalone]


#16

Fromrridge@csclub.uwaterloo.ca (Ross Ridge)
Date2019-03-01 19:04 +0000
Message-ID<q5bvoq$2nu$1@gioia.aioe.org>
In reply to#14
src153  <src153@protocol.invalid> wrote:
> Into the killfile you go.

Please add me to your killfile too.  Thanks.

-- 
 l/  //	  Ross Ridge -- The Great HTMU
[oo][oo]  rridge@csclub.uwaterloo.ca
-()-/()/  http://www.csclub.uwaterloo.ca/~rridge/ 
 db  //	  

[toc] | [prev] | [next] | [standalone]


#17

Fromsrc153 <src153@protocol.invalid>
Date2019-03-01 19:15 +0000
Message-ID<s41j7e9knm9lg001f6o3k8r3l7duuig5g7@4ax.com>
In reply to#16
On Fri, 1 Mar 2019 19:04:58 +0000 (UTC), rridge@csclub.uwaterloo.ca
(Ross Ridge) wrote:

> Please add me to your killfile too.  Thanks.

Do you have a dispute with the subject material? Or do you just like to
associate with trolls?

[toc] | [prev] | [next] | [standalone]


#18

Fromrridge@csclub.uwaterloo.ca (Ross Ridge)
Date2019-03-01 19:20 +0000
Message-ID<q5c0ll$74a$1@gioia.aioe.org>
In reply to#17
rridge@csclub.uwaterloo.ca (Ross Ridge) wrote:
> Please add me to your killfile too.  Thanks.

src153  <src153@protocol.invalid> wrote:
>Do you have a dispute with the subject material? Or do you just like to
>associate with trolls?

I would just like to be added to your killfile as well.  Thanks.

-- 
 l/  //	  Ross Ridge -- The Great HTMU
[oo][oo]  rridge@csclub.uwaterloo.ca
-()-/()/  http://www.csclub.uwaterloo.ca/~rridge/ 
 db  //	  

[toc] | [prev] | [next] | [standalone]


#19

Fromsrc153 <src153@protocol.invalid>
Date2019-03-01 19:31 +0000
Message-ID<u12j7e9kdgt2a7pirkdgpath8edffjt35c@4ax.com>
In reply to#18
On Fri, 1 Mar 2019 19:20:21 +0000 (UTC), rridge@csclub.uwaterloo.ca
(Ross Ridge) wrote:

>> Do you have a dispute with the subject material? Or do you just like to
>> associate with trolls?

> I would just like to be added to your killfile as well.  Thanks.

When it suits me, not you.

[toc] | [prev] | [next] | [standalone]


#21

Fromrridge@csclub.uwaterloo.ca (Ross Ridge)
Date2019-03-01 21:29 +0000
Message-ID<q5c88c$1a7e$1@gioia.aioe.org>
In reply to#19
src153  <src153@protocol.invalid> wrote:
> Do you have a dispute with the subject material? Or do you just like to
> associate with trolls?

rridge@csclub.uwaterloo.ca (Ross Ridge) wrote:
> I would just like to be added to your killfile as well.  Thanks.

src153  <src153@protocol.invalid> wrote:
>When it suits me, not you.

Oh, ok.  You were kind enough to put R.Wieser in your killfile without
him even asking, so I thought it wouldn't be too much of a bother for
you to add me as well.

-- 
 l/  //	  Ross Ridge -- The Great HTMU
[oo][oo]  rridge@csclub.uwaterloo.ca
-()-/()/  http://www.csclub.uwaterloo.ca/~rridge/ 
 db  //	  

[toc] | [prev] | [next] | [standalone]


#22

Fromsrc153 <src153@protocol.invalid>
Date2019-03-01 21:53 +0000
Message-ID<f8aj7eln34csqcpqqlpc5badfd2jquv6u9@4ax.com>
In reply to#21
On Fri, 1 Mar 2019 21:29:48 +0000 (UTC), rridge@csclub.uwaterloo.ca
(Ross Ridge) wrote:

>Oh, ok.  You were kind enough to put R.Wieser in your killfile without
>him even asking, so I thought it wouldn't be too much of a bother for
>you to add me as well.

Can't let it go? Got to have the last word?

Let me guess:

Liberal? Abortion supporter? Evolution believer? 2 out of 3?

[toc] | [prev] | [next] | [standalone]


#25

Fromrridge@csclub.uwaterloo.ca (Ross Ridge)
Date2019-03-01 22:20 +0000
Message-ID<q5cb7p$1o9i$1@gioia.aioe.org>
In reply to#22
src153  <src153@protocol.invalid> wrote:
>Can't let it go? Got to have the last word?

I don't think that's going to be possible, but let's see.

>Let me guess:
>
>Liberal? Abortion supporter? Evolution believer? 2 out of 3?

I doubt anything I could say or do would convince you that it's not
all three.

-- 
 l/  //	  Ross Ridge -- The Great HTMU
[oo][oo]  rridge@csclub.uwaterloo.ca
-()-/()/  http://www.csclub.uwaterloo.ca/~rridge/ 
 db  //	  

[toc] | [prev] | [next] | [standalone]


#29

Fromsrc153 <src153@protocol.invalid>
Date2019-03-01 22:48 +0000
Message-ID<cgdj7e1fvmk8p1uvv1p1eb3ppfilginc50@4ax.com>
In reply to#25
On Fri, 1 Mar 2019 22:20:41 +0000 (UTC), rridge@csclub.uwaterloo.ca
(Ross Ridge) wrote:

>> Liberal? Abortion supporter? Evolution believer? 2 out of 3?

> I doubt anything I could say or do would convince you that it's not
> all three.

Jesus said if they don't believe Moses, they won't believe miracles
either. So if you don't believe Moses, you get none.

[toc] | [prev] | [next] | [standalone]


#31

Fromrridge@csclub.uwaterloo.ca (Ross Ridge)
Date2019-03-01 23:34 +0000
Message-ID<q5cfj2$b29$1@gioia.aioe.org>
In reply to#29
src153  <src153@protocol.invalid> wrote:
>Jesus said if they don't believe Moses, they won't believe miracles
>either. So if you don't believe Moses, you get none.

You're saying you're Moses? 

-- 
 l/  //	  Ross Ridge -- The Great HTMU
[oo][oo]  rridge@csclub.uwaterloo.ca
-()-/()/  http://www.csclub.uwaterloo.ca/~rridge/ 
 db  //	  

[toc] | [prev] | [next] | [standalone]


#32

Fromsrc153 <src153@protocol.invalid>
Date2019-03-01 23:41 +0000
Message-ID<tmgj7elif25oi066jekl8r6c58ueanl5v6@4ax.com>
In reply to#31
On Fri, 1 Mar 2019 23:34:58 +0000 (UTC), rridge@csclub.uwaterloo.ca
(Ross Ridge) wrote:

> You're saying you're Moses? 

No I'm just saying what Jesus said. But you don't believe, do you?

[toc] | [prev] | [next] | [standalone]


#33

Fromrridge@csclub.uwaterloo.ca (Ross Ridge)
Date2019-03-02 00:09 +0000
Message-ID<q5chis$juv$1@gioia.aioe.org>
In reply to#32
rridge@csclub.uwaterloo.ca (Ross Ridge) wrote:>
> You're saying you're Moses? 

src153  <src153@protocol.invalid> wrote:
>No I'm just saying what Jesus said. But you don't believe, do you?

No, I don't believe you're Moses.

-- 
 l/  //	  Ross Ridge -- The Great HTMU
[oo][oo]  rridge@csclub.uwaterloo.ca
-()-/()/  http://www.csclub.uwaterloo.ca/~rridge/ 
 db  //	  

[toc] | [prev] | [next] | [standalone]


#34

Fromsrc153 <src153@protocol.invalid>
Date2019-03-02 00:14 +0000
Message-ID<4kij7e9r8u2om5vdb33jcmqql6b7s5to8b@4ax.com>
In reply to#33
On Sat, 2 Mar 2019 00:09:00 +0000 (UTC), rridge@csclub.uwaterloo.ca
(Ross Ridge) wrote:

>> No I'm just saying what Jesus said. But you don't believe, do you?

> No, I don't believe you're Moses.

You're good at missing the point, as atheists often do.

[toc] | [prev] | [next] | [standalone]


Page 1 of 4  [1] 2 3 4  Next page →

Back to top | Article view | alt.msdos.programmer


csiph-web