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


Groups > comp.lang.c > #100280 > unrolled thread

Reading lines from a file, eliminating CR and LF

Started byAlla _ <modelling.data@gmail.com>
First post2016-12-26 00:31 -0800
Last post2016-12-26 14:38 -0800
Articles 12 on this page of 252 — 20 participants

Back to article view | Back to comp.lang.c


Contents

  Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-26 00:31 -0800
    Re: Reading lines from a file, eliminating CR and LF Barry Schwarz <schwarzb@dqel.com> - 2016-12-26 01:19 -0800
      Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-26 02:25 -0800
        Re: Reading lines from a file, eliminating CR and LF Barry Schwarz <schwarzb@dqel.com> - 2016-12-26 14:04 -0800
    Re: Reading lines from a file, eliminating CR and LF BartC <bc@freeuk.com> - 2016-12-26 12:04 +0000
      Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-26 05:49 -0800
        Re: Reading lines from a file, eliminating CR and LF BartC <bc@freeuk.com> - 2016-12-26 15:20 +0000
          Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-26 07:31 -0800
          Re: Reading lines from a file, eliminating CR and LF Manfred <mx2927@gmail.com> - 2016-12-26 16:44 +0100
            Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-26 08:00 -0800
            Re: Reading lines from a file, eliminating CR and LF BartC <bc@freeuk.com> - 2016-12-26 17:43 +0000
            Re: Reading lines from a file, eliminating CR and LF Keith Thompson <kst-u@mib.org> - 2016-12-26 12:03 -0800
              Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-27 23:56 -0800
                Re: Reading lines from a file, eliminating CR and LF Richard Heathfield <rjh@cpax.org.uk> - 2016-12-28 09:33 +0000
    Re: Reading lines from a file, eliminating CR and LF Manfred <mx2927@gmail.com> - 2016-12-26 17:06 +0100
      Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-26 09:48 -0800
        Re: Reading lines from a file, eliminating CR and LF Manfred <noname@invalid.add> - 2016-12-26 19:03 +0100
          Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-26 10:39 -0800
            Re: Reading lines from a file, eliminating CR and LF BartC <bc@freeuk.com> - 2016-12-26 19:49 +0000
            Re: Reading lines from a file, eliminating CR and LF Manfred <noname@invalid.add> - 2016-12-26 20:56 +0100
              Re: Reading lines from a file, eliminating CR and LF Keith Thompson <kst-u@mib.org> - 2016-12-26 13:50 -0800
                Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-28 00:27 -0800
                  Re: Reading lines from a file, eliminating CR and LF Richard Heathfield <rjh@cpax.org.uk> - 2016-12-28 09:35 +0000
                    Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-28 10:33 -0800
                      Re: Reading lines from a file, eliminating CR and LF Richard Heathfield <rjh@cpax.org.uk> - 2016-12-28 20:48 +0000
                        Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-29 15:31 +0000
                          Re: Reading lines from a file, eliminating CR and LF Richard Heathfield <rjh@cpax.org.uk> - 2016-12-29 18:56 +0000
                        Re: Reading lines from a file, eliminating CR and LF Barry Schwarz <schwarzb@dqel.com> - 2016-12-29 01:03 -0800
                          Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-29 01:33 -0800
                        Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-29 00:16 -0800
                          Re: Reading lines from a file, eliminating CR and LF Richard Heathfield <rjh@cpax.org.uk> - 2016-12-29 14:05 +0000
                            Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-29 23:49 -0800
                  Re: Reading lines from a file, eliminating CR and LF Manfred <noname@invalid.add> - 2016-12-28 15:34 +0100
                  Re: Reading lines from a file, eliminating CR and LF Keith Thompson <kst-u@mib.org> - 2016-12-28 08:49 -0800
                  Re: Reading lines from a file, eliminating CR and LF "James R. Kuyper" <jameskuyper@verizon.net> - 2017-01-04 12:55 -0500
                Re: Reading lines from a file, eliminating CR and LF Tim Rentsch <txr@alumni.caltech.edu> - 2016-12-29 00:19 -0800
                  Re: Reading lines from a file, eliminating CR and LF Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-12-29 13:01 -0800
                  Re: Reading lines from a file, eliminating CR and LF Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-12-29 07:35 -0800
                    Re: Reading lines from a file, eliminating CR and LF supercat@casperkitty.com - 2016-12-29 08:58 -0800
                    Re: Reading lines from a file, eliminating CR and LF raltbos@xs4all.nl (Richard Bos) - 2017-01-01 15:21 +0000
                  Re: Reading lines from a file, eliminating CR and LF Keith Thompson <kst-u@mib.org> - 2016-12-29 09:19 -0800
                    Re: Reading lines from a file, eliminating CR and LF Jean-Marc Bourguet <jm@bourguet.org> - 2016-12-30 08:39 +0100
                      Re: Reading lines from a file, eliminating CR and LF Keith Thompson <kst-u@mib.org> - 2016-12-30 09:02 -0800
                        Re: Reading lines from a file, eliminating CR and LF Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-02 02:22 -0800
                    Re: Reading lines from a file, eliminating CR and LF "Peter \"Shaggy\" Haywood" <phaywood@alphalink.com.au> - 2016-12-31 00:22 +1100
                    Re: Reading lines from a file, eliminating CR and LF Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-02 03:29 -0800
                      Re: Reading lines from a file, eliminating CR and LF supercat@casperkitty.com - 2017-01-02 10:09 -0800
                        Re: Reading lines from a file, eliminating CR and LF Keith Thompson <kst-u@mib.org> - 2017-01-02 14:01 -0800
                          Re: Reading lines from a file, eliminating CR and LF supercat@casperkitty.com - 2017-01-02 16:35 -0800
                            Re: Reading lines from a file, eliminating CR and LF Keith Thompson <kst-u@mib.org> - 2017-01-02 16:49 -0800
                              Re: Reading lines from a file, eliminating CR and LF supercat@casperkitty.com - 2017-01-03 05:32 -0800
                                Re: Reading lines from a file, eliminating CR and LF Keith Thompson <kst-u@mib.org> - 2017-01-03 08:47 -0800
                        Re: Reading lines from a file, eliminating CR and LF luser droog <luser.droog@gmail.com> - 2017-01-02 15:39 -0800
                          Re: Reading lines from a file, eliminating CR and LF supercat@casperkitty.com - 2017-01-02 17:35 -0800
                            Re: Reading lines from a file, eliminating CR and LF luser droog <luser.droog@gmail.com> - 2017-01-02 20:00 -0800
                        Re: Reading lines from a file, eliminating CR and LF Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-13 08:24 -0800
                      Re: Reading lines from a file, eliminating CR and LF Keith Thompson <kst-u@mib.org> - 2017-01-02 13:15 -0800
                        Re: Reading lines from a file, eliminating CR and LF supercat@casperkitty.com - 2017-01-02 17:00 -0800
                          Re: Reading lines from a file, eliminating CR and LF Keith Thompson <kst-u@mib.org> - 2017-01-02 19:48 -0800
                        Re: Reading lines from a file, eliminating CR and LF Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-13 09:32 -0800
                          Re: Reading lines from a file, eliminating CR and LF Keith Thompson <kst-u@mib.org> - 2017-01-13 12:52 -0800
                            Re: Reading lines from a file, eliminating CR and LF Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-15 15:46 -0800
                              Re: Reading lines from a file, eliminating CR and LF Keith Thompson <kst-u@mib.org> - 2017-01-15 16:54 -0800
                                Re: Reading lines from a file, eliminating CR and LF Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-30 11:25 -0800
                                Re: Reading lines from a file, eliminating CR and LF supercat@casperkitty.com - 2017-01-30 14:06 -0800
                  Re: Reading lines from a file, eliminating CR and LF supercat@casperkitty.com - 2016-12-29 06:07 -0800
                    Re: Reading lines from a file, eliminating CR and LF Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-13 15:11 -0800
              Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-27 09:37 -0800
                Re: Reading lines from a file, eliminating CR and LF Manfred <noname@invalid.add> - 2016-12-27 19:29 +0100
                  Re: Reading lines from a file, eliminating CR and LF luser droog <luser.droog@gmail.com> - 2016-12-27 11:41 -0800
                    Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-28 10:30 -0800
                      Re: Reading lines from a file, eliminating CR and LF luser droog <luser.droog@gmail.com> - 2016-12-28 16:08 -0800
                Re: Reading lines from a file, eliminating CR and LF fir <profesor.fir@gmail.com> - 2016-12-27 12:50 -0800
              Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-27 09:59 -0800
                Re: Reading lines from a file, eliminating CR and LF Barry Schwarz <schwarzb@dqel.com> - 2016-12-27 10:56 -0800
                  Re: Reading lines from a file, eliminating CR and LF Keith Thompson <kst-u@mib.org> - 2016-12-27 12:24 -0800
                    Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-28 08:35 -0800
                      Re: Reading lines from a file, eliminating CR and LF Keith Thompson <kst-u@mib.org> - 2016-12-28 09:16 -0800
                        Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-28 10:08 -0800
                  Re: Reading lines from a file, eliminating CR and LF Manfred <noname@invalid.add> - 2016-12-27 22:34 +0100
                    Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-28 08:39 -0800
                  Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-28 02:20 -0800
                  Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-28 10:11 -0800
                    Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-29 00:20 -0800
                      Re: Reading lines from a file, eliminating CR and LF Manfred <noname@invalid.add> - 2016-12-29 14:56 +0100
                        Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-29 22:35 -0800
                          Re: Reading lines from a file, eliminating CR and LF Manfred <noname@invalid.add> - 2016-12-30 22:45 +0100
                            Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-31 00:01 +0000
                              Re: Reading lines from a file, eliminating CR and LF Manfred <noname@invalid.add> - 2016-12-31 03:19 +0100
                            Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-31 00:20 -0800
                            Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-31 00:23 -0800
                            Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-31 00:29 -0800
                              Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-31 11:10 +0000
                                Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-31 10:53 -0800
                                  Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-31 20:24 +0000
                    Re: Reading lines from a file, eliminating CR and LF Barry Schwarz <schwarzb@dqel.com> - 2016-12-29 00:53 -0800
                      Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-29 01:28 -0800
                        Re: Reading lines from a file, eliminating CR and LF Manfred <noname@invalid.add> - 2016-12-29 14:48 +0100
                          Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-29 22:19 -0800
                      Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-29 01:55 -0800
                        Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-29 10:14 -0800
                          Re: Reading lines from a file, eliminating CR and LF Keith Thompson <kst-u@mib.org> - 2016-12-29 11:44 -0800
                          Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-30 02:02 +0000
                            Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-30 03:13 -0800
                              Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-30 14:49 +0000
                            Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-30 03:28 -0800
                              Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-30 03:45 -0800
                              Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-30 13:53 +0000
                                Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-30 08:23 -0800
                            Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-30 03:50 -0800
                              Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-30 13:35 +0000
                                Re: Reading lines from a file, eliminating CR and LF Richard Heathfield <rjh@cpax.org.uk> - 2016-12-30 15:22 +0000
                                  Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-30 08:29 -0800
                                  Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-30 16:51 +0000
                                Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-31 10:50 -0800
                                  Re: Reading lines from a file, eliminating CR and LF BartC <bc@freeuk.com> - 2016-12-31 19:02 +0000
                                  Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-31 20:10 +0000
                                    Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-01 04:08 -0800
                                      Re: Reading lines from a file, eliminating CR and LF Richard Heathfield <rjh@cpax.org.uk> - 2017-01-01 12:38 +0000
                                        Re: Reading lines from a file, eliminating CR and LF BartC <bc@freeuk.com> - 2017-01-01 13:45 +0000
                                          Re: Reading lines from a file, eliminating CR and LF BartC <bc@freeuk.com> - 2017-01-01 13:54 +0000
                                        Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-01 15:26 +0000
                                          Re: Reading lines from a file, eliminating CR and LF Richard Heathfield <rjh@cpax.org.uk> - 2017-01-01 16:46 +0000
                                            Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-01 17:08 +0000
                                        Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-01 08:13 -0800
                                          Re: Reading lines from a file, eliminating CR and LF Richard Heathfield <rjh@cpax.org.uk> - 2017-01-01 16:47 +0000
                                          Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-01 16:53 +0000
                                            Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-01 09:18 -0800
                                              Re: Reading lines from a file, eliminating CR and LF Manfred <noname@invalid.add> - 2017-01-01 19:20 +0100
                                          Re: Reading lines from a file, eliminating CR and LF Barry Schwarz <schwarzb@dqel.com> - 2017-01-01 15:18 -0800
                                            Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-02 03:41 -0800
                                      Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-01 15:07 +0000
                                        Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-01 09:05 -0800
                                          Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-01 19:16 +0000
                                            Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-02 03:39 -0800
                                              Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-02 04:02 -0800
                                                Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-02 13:48 +0000
                                              Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-02 13:47 +0000
                                                Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-02 07:21 -0800
                                                  Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-02 18:38 +0000
                                                    Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-02 10:57 -0800
                                                      Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-02 21:48 +0000
                                                  POSIX, was: Re: Reading lines from a file, eliminating CR and LF luser droog <luser.droog@gmail.com> - 2017-01-02 15:58 -0800
                                  Re: Reading lines from a file, eliminating CR and LF Barry Schwarz <schwarzb@dqel.com> - 2016-12-31 21:03 -0800
                                Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-02 11:30 -0800
                                  Re: Reading lines from a file, eliminating CR and LF Richard Heathfield <rjh@cpax.org.uk> - 2017-01-02 19:45 +0000
                                    Re: Reading lines from a file, eliminating CR and LF Ike Naar <ike@iceland.freeshell.org> - 2017-01-02 19:56 +0000
                                      Re: Reading lines from a file, eliminating CR and LF Richard Heathfield <rjh@cpax.org.uk> - 2017-01-02 21:09 +0000
                                        Re: Reading lines from a file, eliminating CR and LF Ian Collins <ian-news@hotmail.com> - 2017-01-03 11:01 +1300
                                          Re: Reading lines from a file, eliminating CR and LF Richard Heathfield <rjh@cpax.org.uk> - 2017-01-03 12:45 +0000
                                            Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-03 14:09 +0000
                                              Re: Reading lines from a file, eliminating CR and LF Richard Heathfield <rjh@cpax.org.uk> - 2017-01-03 15:07 +0000
                                            Re: Reading lines from a file, eliminating CR and LF Ian Collins <ian-news@hotmail.com> - 2017-01-04 09:13 +1300
                                      Re: Reading lines from a file, eliminating CR and LF Ian Collins <ian-news@hotmail.com> - 2017-01-03 11:53 +1300
                                        Re: Reading lines from a file, eliminating CR and LF Malcolm McLean <malcolm.mclean5@btinternet.com> - 2017-01-02 15:40 -0800
                                          Re: Reading lines from a file, eliminating CR and LF Ian Collins <ian-news@hotmail.com> - 2017-01-03 13:16 +1300
                                        Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-03 00:01 +0000
                                          Re: Reading lines from a file, eliminating CR and LF Ian Collins <ian-news@hotmail.com> - 2017-01-03 13:21 +1300
                                        Re: Reading lines from a file, eliminating CR and LF Ike Naar <ike@iceland.freeshell.org> - 2017-01-03 08:40 +0000
                                        Re: Reading lines from a file, eliminating CR and LF Richard Heathfield <rjh@cpax.org.uk> - 2017-01-03 12:50 +0000
                                          Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-03 14:42 +0000
                                            Re: Reading lines from a file, eliminating CR and LF Richard Heathfield <rjh@cpax.org.uk> - 2017-01-03 15:11 +0000
                                              Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-03 16:32 +0000
                                                Re: Reading lines from a file, eliminating CR and LF Richard Heathfield <rjh@cpax.org.uk> - 2017-01-03 17:24 +0000
                                                  Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-03 17:48 +0000
                                                    Re: Reading lines from a file, eliminating CR and LF Richard Heathfield <rjh@cpax.org.uk> - 2017-01-03 18:56 +0000
                                                      Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-03 19:46 +0000
                                                      Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-03 13:37 -0800
                                    Re: Reading lines from a file, eliminating CR and LF Barry Schwarz <schwarzb@dqel.com> - 2017-01-02 13:56 -0800
                                    Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-03 03:52 -0800
                                      Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-03 14:20 +0000
                                        Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-03 13:19 -0800
                                          Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-04 03:30 +0000
                                            Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-04 02:23 -0800
                                              Re: Reading lines from a file, eliminating CR and LF mark.bluemel@gmail.com - 2017-01-04 02:56 -0800
                                                Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-04 07:06 -0800
                                                  Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-04 15:21 +0000
                                                    Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-05 03:01 -0800
                                                      Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-05 11:51 +0000
                                                        Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-05 04:04 -0800
                                                          Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-05 14:23 +0000
                                                  Re: Reading lines from a file, eliminating CR and LF Barry Schwarz <schwarzb@dqel.com> - 2017-01-04 12:26 -0800
                                                    Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-05 13:38 -0800
                                                      Re: Reading lines from a file, eliminating CR and LF Barry Schwarz <schwarzb@dqel.com> - 2017-01-05 16:25 -0800
                                              Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-04 12:21 +0000
                                                Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-05 02:52 -0800
                                                  Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-05 14:13 +0000
                                                    Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-05 07:54 -0800
                                                    Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-05 07:59 -0800
                                                    Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-05 08:12 -0800
                                                      Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-05 17:15 +0000
                                                        Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-05 09:19 -0800
                                                    Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-05 08:28 -0800
                                                      Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-05 17:20 +0000
                                                        Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-05 10:45 -0800
                                                    Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-05 09:02 -0800
                                                      Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-05 19:49 +0000
                                                        Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-05 13:28 -0800
                                                          Re: Reading lines from a file, eliminating CR and LF Barry Schwarz <schwarzb@dqel.com> - 2017-01-05 16:14 -0800
                                                          Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-06 00:50 +0000
                                                            Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-06 06:11 -0800
                                                              Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-06 16:33 +0000
                                                                Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-06 12:14 -0800
                                                                Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-07 02:15 -0800
                                                                  Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-07 21:51 +0000
                                                                Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-07 03:32 -0800
                                                                  Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-07 21:57 +0000
                                                                    Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-08 01:51 -0800
                                                                    Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-08 02:09 -0800
                                                                Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-07 04:09 -0800
                                                                  Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-07 22:05 +0000
                                                                    Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-08 03:43 -0800
                                                                      Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-08 21:36 +0000
                                                                        Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-09 04:33 -0800
                                                                          Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-09 21:44 +0000
                                                                            Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-09 23:54 -0800
                                                                            Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-10 02:04 -0800
                                                                              Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-10 11:28 +0000
                                                                                Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-10 04:25 -0800
                                                                                  Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-10 14:14 +0000
                                                                                    Re: Reading lines from a file, eliminating CR and LF Richard Heathfield <rjh@cpax.org.uk> - 2017-01-10 14:52 +0000
                                                                                    Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-10 07:02 -0800
                                                                                    Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-12 00:11 -0800
                                                                                      Re: Reading lines from a file, eliminating CR and LF mark.bluemel@gmail.com - 2017-01-12 01:13 -0800
                                                                                        Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-12 01:41 -0800
                                                                                      Re: Reading lines from a file, eliminating CR and LF Richard Heathfield <rjh@cpax.org.uk> - 2017-01-12 09:55 +0000
                                                                                        Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-12 10:25 -0800
                                                                      Re: Reading lines from a file, eliminating CR and LF Barry Schwarz <schwarzb@dqel.com> - 2017-01-08 19:02 -0800
                                                                        Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-09 05:27 -0800
                                                              Re: Reading lines from a file, eliminating CR and LF Manfred <noname@invalid.add> - 2017-01-07 17:06 +0100
                                                                Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-07 08:11 -0800
                                                  Re: Reading lines from a file, eliminating CR and LF Barry Schwarz <schwarzb@dqel.com> - 2017-01-05 16:04 -0800
                                              Re: Reading lines from a file, eliminating CR and LF Barry Schwarz <schwarzb@dqel.com> - 2017-01-04 12:36 -0800
                                                Re: Reading lines from a file, eliminating CR and LF Keith Thompson <kst-u@mib.org> - 2017-01-04 12:49 -0800
                                            Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-04 05:19 -0800
                                              Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-04 15:14 +0000
                                                Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-05 02:57 -0800
                                                  Re: Reading lines from a file, eliminating CR and LF Keith Thompson <kst-u@mib.org> - 2017-01-05 08:24 -0800
                                                Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-05 02:58 -0800
                                              Re: Reading lines from a file, eliminating CR and LF Barry Schwarz <schwarzb@dqel.com> - 2017-01-04 13:02 -0800
                                    Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-03 03:37 -0800
                                    Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-03 02:46 -0800
                                      Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-03 11:25 +0000
                                    Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2017-01-03 02:43 -0800
                                  Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-02 22:45 +0000
                        Re: Reading lines from a file, eliminating CR and LF Barry Schwarz <schwarzb@dqel.com> - 2016-12-29 10:17 -0800
                          Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-30 00:42 -0800
                          Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-30 00:51 -0800
                        Re: Reading lines from a file, eliminating CR and LF Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-29 11:25 +0000
                    Re: Reading lines from a file, eliminating CR and LF Manfred <noname@invalid.add> - 2016-12-28 20:57 +0100
                      Re: Reading lines from a file, eliminating CR and LF Alla _ <modelling.data@gmail.com> - 2016-12-28 23:16 -0800
            Re: Reading lines from a file, eliminating CR and LF Barry Schwarz <schwarzb@dqel.com> - 2016-12-26 14:38 -0800

Page 13 of 13 — ← Prev page 1 … 11 12 [13]


#100958

FromAlla _ <modelling.data@gmail.com>
Date2017-01-03 03:37 -0800
Message-ID<08622fe5-346a-4c96-9b3e-2bf3185f2e54@googlegroups.com>
In reply to#100895
On Tuesday, January 3, 2017 at 2:25:46 PM UTC+3, Ben Bacarisse wrote:
> Alla _ <modelling.data@gmail.com> writes:
> 
> > On Monday, January 2, 2017 at 10:45:35 PM UTC+3, Richard Heathfield wrote:
> >> On 02/01/17 19:30, Alla _ wrote:
> >> > bool check_line(char *ptr, size_t line)
> >> > {
> >> >     while(*ptr)
> >> >     {
> >> >         //Ignore the sign
> >> >         if( (*ptr == '-' || *ptr == '+' ||
> >> >              *ptr == '.') && *(ptr+1) != '\0')
> >> >             ptr++;
> >> >         //Check for non-numerical characters
> >> >         if (!isdigit(*ptr))
> >> >         {
> >> >             fprintf(stderr, "The line '%zu' contains non-numerical values.\n", line);
> >> >             return true;
> >> >         }
> >> >         ptr++;
> >> >     }
> >> >     return false;
> >> > }
> >> 
> >> You can replace this with:
> >> 
> >> bool check_line(char *ptr, size_t line)
> >> {
> >>    char *endptr = NULL;
> >>    strtod(ptr, &endptr);
> >>    if(ptr == endptr)
> >>    {
> >>      fprintf(stderr,
> >>              "The line '%zu' contains non-numerical values.\n",
> >>              line);
> >>    }
> >>    return ptr == endptr;
> >> }
> >> 
> >> If you can do without the pointless noise, the function can be reduced 
> >> to this:
> >> 
> >> bool check_line(char *ptr)
> >> {
> >>    char *endptr = NULL;
> >>    strtod(ptr, endptr);
> >>    return ptr == endptr;
> >> }
> >> 
> > <snip>
> > I thought that I need to loop through the whole line anyway,
> > because according to the spec I have to ignore each line
> > that contains a non-numerical value, and this value can
> > be anywhere in the line, not only at the particular location.
> > I guess this piece has to be in the while loop. Am I wrong?
> 
> You don't need to loop through the whole line -- that's just the way you
> are currently thinking about it -- but you are right that Richard's
> version does not solve the problem, and I don't think he was actually
> trying to either.  I think the point he was making is that your function
> is simply trying to do that same scanning that strtod does.
> 
> Here's a tip: strtod gives you back a pointer to the first first
> character that was not part of a number.  Just think how useful that is!
> And remember, if you find yourself writing more than a very few lines,
> your are over complicating things.
Thank you very much. I see. Hope to be back with a feasible solution )

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


#100960

FromAlla _ <modelling.data@gmail.com>
Date2017-01-03 02:46 -0800
Message-ID<6466708f-c0ee-457d-b1e8-e7817949c410@googlegroups.com>
In reply to#100895
On Monday, January 2, 2017 at 10:45:35 PM UTC+3, Richard Heathfield wrote:
> On 02/01/17 19:30, Alla _ wrote:
> > bool check_line(char *ptr, size_t line)
> > {
> >     while(*ptr)
> >     {
> >         //Ignore the sign
> >         if( (*ptr == '-' || *ptr == '+' ||
> >              *ptr == '.') && *(ptr+1) != '\0')
> >             ptr++;
> >         //Check for non-numerical characters
> >         if (!isdigit(*ptr))
> >         {
> >             fprintf(stderr, "The line '%zu' contains non-numerical values.\n", line);
> >             return true;
> >         }
> >         ptr++;
> >     }
> >     return false;
> > }
> 
> You can replace this with:
> 
> bool check_line(char *ptr, size_t line)
> {
>    char *endptr = NULL;
>    strtod(ptr, &endptr);
>    if(ptr == endptr)
>    {
>      fprintf(stderr,
>              "The line '%zu' contains non-numerical values.\n",
>              line);
>    }
>    return ptr == endptr;
> }
> 
> If you can do without the pointless noise, the function can be reduced 
> to this:
> 
> bool check_line(char *ptr)
> {
>    char *endptr = NULL;
>    strtod(ptr, endptr);
>    return ptr == endptr;
> }
> 
<snip>
I thought that I need to loop through the whole line anyway,
because according to the spec I have to ignore each line
that contains a non-numerical value, and this value can
be anywhere in the line, not only at the particular location.
I guess this piece has to be in the while loop. Am I wrong?

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


#100965

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2017-01-03 11:25 +0000
Message-ID<87wpecidvw.fsf@bsb.me.uk>
In reply to#100960
Alla _ <modelling.data@gmail.com> writes:

> On Monday, January 2, 2017 at 10:45:35 PM UTC+3, Richard Heathfield wrote:
>> On 02/01/17 19:30, Alla _ wrote:
>> > bool check_line(char *ptr, size_t line)
>> > {
>> >     while(*ptr)
>> >     {
>> >         //Ignore the sign
>> >         if( (*ptr == '-' || *ptr == '+' ||
>> >              *ptr == '.') && *(ptr+1) != '\0')
>> >             ptr++;
>> >         //Check for non-numerical characters
>> >         if (!isdigit(*ptr))
>> >         {
>> >             fprintf(stderr, "The line '%zu' contains non-numerical values.\n", line);
>> >             return true;
>> >         }
>> >         ptr++;
>> >     }
>> >     return false;
>> > }
>> 
>> You can replace this with:
>> 
>> bool check_line(char *ptr, size_t line)
>> {
>>    char *endptr = NULL;
>>    strtod(ptr, &endptr);
>>    if(ptr == endptr)
>>    {
>>      fprintf(stderr,
>>              "The line '%zu' contains non-numerical values.\n",
>>              line);
>>    }
>>    return ptr == endptr;
>> }
>> 
>> If you can do without the pointless noise, the function can be reduced 
>> to this:
>> 
>> bool check_line(char *ptr)
>> {
>>    char *endptr = NULL;
>>    strtod(ptr, endptr);
>>    return ptr == endptr;
>> }
>> 
> <snip>
> I thought that I need to loop through the whole line anyway,
> because according to the spec I have to ignore each line
> that contains a non-numerical value, and this value can
> be anywhere in the line, not only at the particular location.
> I guess this piece has to be in the while loop. Am I wrong?

You don't need to loop through the whole line -- that's just the way you
are currently thinking about it -- but you are right that Richard's
version does not solve the problem, and I don't think he was actually
trying to either.  I think the point he was making is that your function
is simply trying to do that same scanning that strtod does.

Here's a tip: strtod gives you back a pointer to the first first
character that was not part of a number.  Just think how useful that is!
And remember, if you find yourself writing more than a very few lines,
your are over complicating things.

-- 
Ben.

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


#100961

FromAlla _ <modelling.data@gmail.com>
Date2017-01-03 02:43 -0800
Message-ID<e34de2ba-d67d-43cb-8928-4e0c7e118788@googlegroups.com>
In reply to#100895
On Monday, January 2, 2017 at 10:45:35 PM UTC+3, Richard Heathfield wrote:
> On 02/01/17 19:30, Alla _ wrote:
> > bool check_line(char *ptr, size_t line)
> > {
> >     while(*ptr)
> >     {
> >         //Ignore the sign
> >         if( (*ptr == '-' || *ptr == '+' ||
> >              *ptr == '.') && *(ptr+1) != '\0')
> >             ptr++;
> >         //Check for non-numerical characters
> >         if (!isdigit(*ptr))
> >         {
> >             fprintf(stderr, "The line '%zu' contains non-numerical values.\n", line);
> >             return true;
> >         }
> >         ptr++;
> >     }
> >     return false;
> > }
> 
> You can replace this with:
> 
> bool check_line(char *ptr, size_t line)
> {
>    char *endptr = NULL;
>    strtod(ptr, &endptr);
>    if(ptr == endptr)
>    {
>      fprintf(stderr,
>              "The line '%zu' contains non-numerical values.\n",
>              line);
>    }
>    return ptr == endptr;
> }
> 
> If you can do without the pointless noise, the function can be reduced 
> to this:
> 
> bool check_line(char *ptr)
> {
>    char *endptr = NULL;
>    strtod(ptr, endptr);
>    return ptr == endptr;
> }
> 
Thank you very much for your help. I'll dare to express the only
thing that bothers me: you are a revered C pro and do know 
every nook and cranny of C, and can come up with a solution 
to any problem within a fraction of a second, but solving problems 
for me and each time showing me your code doesn't help me to develop 
my own ability to think. I know it's very very tedious to guide someone 
to the right outcome, but this guidance helps to develop the thinking process. 
Of course, copying and learning the correct code is also a very
great tool in learning, but not each time, and not for simple matters.
Also it would be truly helpful if you show my errors in the code I 
post, and not simply come up with another correct version - if 
I don't understand what I am doing wrong, how will I improve? )

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


#100919

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2017-01-02 22:45 +0000
Message-ID<87pok5jd3m.fsf@bsb.me.uk>
In reply to#100894
Alla _ <modelling.data@gmail.com> writes:
<snip>
> It's the second program.

You need to go back a version.  The last changes you made to the first
program have made things worse (I've posted about that in another
reply).  Those issues are not related to this problem, but it will get
confusing if people are trying to explain several things at once.

Starting from that better base, if you find your changes are more than a
few lines, things have gone wrong.

Good luck!

<snip>
-- 
Ben.

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


#100574

FromBarry Schwarz <schwarzb@dqel.com>
Date2016-12-29 10:17 -0800
Message-ID<p7ia6clqi0qhs08ha897qco551ho15b80k@4ax.com>
In reply to#100571
On Thu, 29 Dec 2016 01:55:38 -0800 (PST), Alla _
<modelling.data@gmail.com> wrote:

>Please, take a look at this version. I don't need any non-numeric characters
>after digital ones, therefore I do not use isalnum here. 
>I now intend to use this version in my values converting function. Is it all right?
>#include <stdio.h>
>#include <stdlib.h>
>#include <ctype.h>
>#include <string.h>
>#include <stdbool.h>
>
>#define BUFFER_SIZE 100
>#define INCOME_STATEMENT "../files/income_test.csv"
>
>bool get_line (FILE *input_file);
>bool unprintable(char *buffer);
>
>int main(int argc, char *argv[])
>{
>    //Check for correct number of arguments
>    if(argc > 2)
>    {
>        fputs("Sorry, the program processes only one file.\n", stderr);
>        return EXIT_FAILURE;
>    }
>    //Determine a file to use
>    const char *data_file = (argc == 2)? argv[1] : INCOME_STATEMENT;
>    
>    FILE *fp = fopen(data_file, "r");
>    
>    if ( fp )
>    {
>        if( !get_line(fp) )
>        {
>            puts("Reading csv file failed");
>            return EXIT_FAILURE;

While not strictly necessary, it is still good practice to close your
open files before exiting.  The system will probably do it for you
when main exits but what happens if you ever decide to use this code
as a subroutine in a different program.  You may no longer be
returning from main and now would have a memory leak.

>        }
>        fclose(fp);
>        return EXIT_SUCCESS;
>    }
>    //Couldn't open the file
>    else

Not so much an error as a sign of incomplete analysis.  Both the
"else" and its accompanying braces are superfluous.  Your code cannot
reach this point if if(fp) is true.  Notice that you seemed to
recognize this situation regarding if(!get_line) and did not code an
else statement after that closing brace.

>    {
>        perror(data_file);

fopen is not required to set errno.  Therefore you should set it to 0
before the call to insure this prints only fopen related text.  

And if fopen does not set errno, this will print just the file name
with no indication that there was a problem.  Hardly a suitable error
message.  You might want to look at the strerror function.  Something
like
     printf("%s - %s\n", data_file, errno ? strerror(errno) : "Open
failure!");

>    }
>    return EXIT_FAILURE;

And if code could reach the else, then this return statement needs to
be inside the braces.

>}
>
>/** Function to read and process the data
> from the file line by line
> **/
>
>bool get_line (FILE *input_file)
>{
>    char buffer[BUFFER_SIZE] = "";
>    size_t line = 0;
>    size_t index;
>    
>    //Read each line from the file, store in the buffer
>    while(fgets(buffer, sizeof(buffer), input_file) != NULL)
>    {
>        line++;
>        //DEBUG
>        puts("*****************************");
>        printf("Buffer beg:: %s\n", buffer);
>        
>        index = strlen(buffer) - 1;
>        
>        /* Finish the buffer at the last digit
>           in the line */
>        while(!isdigit(buffer[index]))
>            index--;
>        buffer[index+1] = '\0';
>
>        /* Check for any unprintable characters
>          within the line */
>        if(unprintable(buffer))
>        {
>            puts("CSV file contains unprintable characters");

It would be nice to tell the user which line in the file is defective.

>            puts("Please, correct the file and try again");
>            return false;
>        }
>        printf("Buffer end:: %s\n", buffer);
>    }
>    
>    if (ferror(input_file))
>    {
>        puts("Something went wrong with the provided file\n");

ferror is not required to set errno either but it is a little
inconsistent that you didn't use perror here also.  

It would be nice to give the user a meaningful diagnostic.  Something
along the lines of
    "get_line detected an error reading the file.  Last input
processed was" and then print buffer.

>        return false;
>    }
>    return true;
>}
>
>/** Find unprintable characters in array
>    other than LF and CR
> **/
>bool unprintable(char *buffer)
>{
>    while(*buffer != '\0')
>    {
>        if(!isprint(*buffer))
>            return true;
>        buffer++;
>    }
>    return false;
>}

-- 
Remove del for email

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


#100631

FromAlla _ <modelling.data@gmail.com>
Date2016-12-30 00:42 -0800
Message-ID<c324a0b6-c812-4d73-b477-5601d2d71cac@googlegroups.com>
In reply to#100574
On Thursday, December 29, 2016 at 9:18:00 PM UTC+3, Barry Schwarz wrote:
> On Thu, 29 Dec 2016 01:55:38 -0800 (PST), Alla _
> <modelling.data@gmail.com> wrote:
<snip>
> While not strictly necessary, it is still good practice to close your
> open files before exiting.  The system will probably do it for you
> when main exits but what happens if you ever decide to use this code
> as a subroutine in a different program.  You may no longer be
> returning from main and now would have a memory leak.
Yes; this is my mistake , which I have missed; I try to use close before each
exit.
<snip>
> >    //Couldn't open the file
> >    else
> 
> Not so much an error as a sign of incomplete analysis.  Both the
> "else" and its accompanying braces are superfluous.  Your code cannot
> reach this point if if(fp) is true.  Notice that you seemed to
> recognize this situation regarding if(!get_line) and did not code an
> else statement after that closing brace.
Yes, it is lack of attention  - I was preoccupied with core functions of the 
program, and have completely left out the design of the main function. 
> 
> >    {
> >        perror(data_file);
> 
> fopen is not required to set errno.  Therefore you should set it to 0
> before the call to insure this prints only fopen related text.  
I have not yet studied the whole error generating and reporting
topic; I have read only few pieces on it, and have hardly understood
it yet. Thank you for pointing this out, so I have found the material
that helped me to understand the topic a bit better

https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=6619179

Here is my code:
//Determine a file to use
    const char *data_file = (argc == 2)? argv[1] : INCOME_STATEMENT;
    errno = 0;
    
    FILE *fp = fopen(data_file, "r");
    
    if ( fp )
    {
        if( !get_line(fp) )
        {
            puts("Reading csv file failed");
            fclose(fp);
            return EXIT_FAILURE;
        }
        fclose(fp);
        return EXIT_SUCCESS;
    }
    //Couldn't open the file
    printf("%s - %s\n", data_file, errno ? strerror(errno) : "Openfailure!");
           
    return EXIT_FAILURE;
<snip>

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


#100632

FromAlla _ <modelling.data@gmail.com>
Date2016-12-30 00:51 -0800
Message-ID<7646361f-181e-4b56-b495-05efd0702d61@googlegroups.com>
In reply to#100574
On Thursday, December 29, 2016 at 9:18:00 PM UTC+3, Barry Schwarz wrote:
> On Thu, 29 Dec 2016 01:55:38 -0800 (PST), Alla _
> <modelling.data@gmail.com> wrote:
> 
<snip>
> >        /* Check for any unprintable characters
> >          within the line */
> >        if(unprintable(buffer))
> >        {
> >            puts("CSV file contains unprintable characters");
> 
> It would be nice to tell the user which line in the file is defective.
> 
> >            puts("Please, correct the file and try again");
> >            return false;
> >        }
Agree ) Corrected:
/** Find unprintable characters in array
    other than LF and CR
 **/
bool unprintable(char *buffer, size_t line)
{
    int index = 0;
    while(*buffer != '\0')
    {
        if(!isprint((unsigned char)*buffer))
        {
            printf("Unprintable character found at buffer[%i] on line %zu\n", index, line);
            return true;
        }
        buffer++;
        index++;
    }
    return false;
}

<snip>

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


#100614

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2016-12-29 11:25 +0000
Message-ID<87ful7dlk5.fsf@bsb.me.uk>
In reply to#100571
Alla _ <modelling.data@gmail.com> writes:

<snip>

> Please, take a look at this version. I don't need any non-numeric characters
> after digital ones, therefore I do not use isalnum here. 
> I now intend to use this version in my values converting function. Is
> it all right?

No, I'd say there is a bug, but the real problem is that you are still
looking for problems rather than acting on success.  You've spent a lot
of time with programs that look for \r when (as far as I know) you don't
want any \r characters.  A stray \r is no different to a stray # or \a
or any other odd thing you don't expect.

The most robust programs work by looking for the data they need and then
only continuing when they find it.  They don't care about all the many
ways in which the input might be malformed (except when they absolutely
must provide detailed explanations of problems).  This strategy will
also, as if by magic, solve the problems with last lines being or not
being terminated by a newline.  Since you don't care about that, there
is no reason for your program to take any special action either.  You
process the valid data that you find in a line buffer.  When the data
you need are not there, your program simply stops, with some message
like "Malformed data on line 54 of file xyz.csv".

In this fragment your plan seems to be to find a character you don't
need (the last non-digit) and only then will you start to look for the
data you need.  That's backwards -- look for what you need and complain
to the user when you don't find it.

Now for that bug...

> bool get_line (FILE *input_file)
> {
>     char buffer[BUFFER_SIZE] = "";
>     size_t line = 0;
>     size_t index;
>     
>     //Read each line from the file, store in the buffer
>     while(fgets(buffer, sizeof(buffer), input_file) != NULL)
>     {
<snip>
>         index = strlen(buffer) - 1;
<snip>
>         while(!isdigit(buffer[index]))
>             index--;
>         buffer[index+1] = '\0';

What happens when the line is empty, i.e. buffer contains only "\n"?
What if it contains only "abc,def,ghi\n"?

>         /* Check for any unprintable characters
>           within the line */
>         if(unprintable(buffer))

Why do you care?

<snip>
> /** Find unprintable characters in array
>     other than LF and CR
>  **/

A detail: this function reports CR and LF as well.  You may call it in
such a way that it will never see them, but the function's definition
(and comments) should not assume some limited context like that.

Another: if you asked someone to find your car keys, would you be happy
if, after a few minutes, they just called out "yes"?  Functions
described as finding something should probably say where.  (To be clear,
this is a remark about the comment -- the function is fine simply
reporting the presence of some class of characters.)

> bool unprintable(char *buffer)
> {
>     while(*buffer != '\0')
>     {
>         if(!isprint(*buffer))

Technically, you should write !isprint((unsigned char)*buffer) here if
you want the code to be portable.  This is one of the nasty bits of C's
history that has stuck around.  (The same applies to all the isxxx
functions and macros.)

>             return true;
>         buffer++;
>     }
>     return false;
> }

-- 
Ben.

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


#100545

FromManfred <noname@invalid.add>
Date2016-12-28 20:57 +0100
Message-ID<o415es$1lg8$1@gioia.aioe.org>
In reply to#100454
On 12/28/2016 7:11 PM, Alla _ wrote:
> On Tuesday, December 27, 2016 at 9:56:54 PM UTC+3, Barry Schwarz wrote:
<snip>
>> You are still in love with unnecessary processing.
> <snip>
> I still have not implemented strpbrk, but, please, take a look at
> what I have achieved.
Regardless of strpbrk, I think it is still somehow overdone. See below.

<snip>
> /** Function to read and process the data
>  from the file line by line
>  **/
>
> bool get_line (FILE *input_file)
> {
>     char buffer[BUFFER_SIZE] = "";
>     size_t line = 0;
>     size_t index;
>
>     //Read each line from the file, store in the buffer
>     while(fgets(buffer, sizeof(buffer), input_file) != NULL)
>     {
>         line++;
>         //DEBUG
>         puts("*****************************");
>         printf("Buffer beg:: %s\n", buffer);
>
>         //Check for CR
Personally, I still think that this found_newline action does not 
require an external function - it can be achieved with 3 lines of code 
(2 with strpbrk).
In fact, the implementation of found_newline has a bug that shows up later.
>         if ( !found_newline(buffer, &index) )
>             puts("The newline character is not found");
>
>         //Check for any other unprintable characters
>         if(unprintable(buffer))
>         {
>             puts("CSV file contains unprintable characters");
>             puts("Please, correct the file and try again");
>             return false;
>         }
>
Your found_newline function does not always set index, and when this 
happens the next statement leads to unpredictable results.
Still I am not convinced that removing the trailing commas here is a 
good idea.
Finally (for this stage) depending on how many times you want the debug 
message to be printed, the following could be a bit more straightforward 
and compact
>         //Delete any trailing commas
>         if(buffer[index-1] == ',')
>         {
>             index--;
>             while(buffer[index] == ',')
>                 index--;
>             buffer[index+1] = '\0';
>             //DEBUG
>             printf("Comma found; buffer ends at [%zu]:: %s\n", index+1, buffer);
>         }
>     }
>
<snip>
Now, this. The function has a bug and an important design flaw.
I'll describe the the bug later at its point, and the flaw here:
You are using 4 (four) different variables to represent the same program 
element, i.e. the line terminator, namely:
- index
- found_r
- found_n
- found_char
Isn't it overcomplicating things? Obviously it requires much more effort 
(and a mistake is easier to make) to manage four variables that one!
> /** Find the newline character **/
> bool found_newline(char *buffer, size_t *index)
> {
>     char *found_r = NULL;
>     char *found_n = NULL;
>     char *found_char = NULL;
>     const char newline_r = '\r';
>     const char newline_n = '\n';
>
>     //Check for CR or LF
This logic works, but you see here already that instead of using 
found_r, found_n and found_char you could use one variable for all of 
them, and if you did so...
>     if ( ((found_r = strchr(buffer, newline_r)) != NULL)
>         || ((found_n = strchr(buffer, newline_n)) != NULL) )
>     {
...the next statement would not be needed
>         found_char = (found_r) ? found_r : found_n;
>         *index = found_char - buffer;
>
>         if(buffer == found_char)
>         {
>             printf("Buffer is empty; please, check the input data\n");
>             return false;
>         }
>         *found_char = '\0';
>
>         return true;
>     }
Here is the bug: if buffer has no CR/LF, then 'index' is not set.
Since you used 4 variables to represent the line terminator, it is no 
surprise that you missed to ensure that one of them was properly set. 
Unfortunately it is the one that you are returning to the caller.
>     return false;
> }
>

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


#100595

FromAlla _ <modelling.data@gmail.com>
Date2016-12-28 23:16 -0800
Message-ID<ab4e5d8f-3474-4474-b4e8-6ba2971e1141@googlegroups.com>
In reply to#100545
On Wednesday, December 28, 2016 at 10:57:24 PM UTC+3, Manfred wrote:
> On 12/28/2016 7:11 PM, Alla _ wrote:
> > On Tuesday, December 27, 2016 at 9:56:54 PM UTC+3, Barry Schwarz wrote:
> <snip>
<snip>
> <snip>
> Now, this. The function has a bug and an important design flaw.
> I'll describe the the bug later at its point, and the flaw here:
> You are using 4 (four) different variables to represent the same program 
> element, i.e. the line terminator, namely:
> - index
> - found_r
> - found_n
> - found_char
> Isn't it overcomplicating things? Obviously it requires much more effort 
> (and a mistake is easier to make) to manage four variables that one!
> > /** Find the newline character **/
> > bool found_newline(char *buffer, size_t *index)
> > {
> >     char *found_r = NULL;
> >     char *found_n = NULL;
> >     char *found_char = NULL;
> >     const char newline_r = '\r';
> >     const char newline_n = '\n';
> >
> >     //Check for CR or LF
> This logic works, but you see here already that instead of using 
> found_r, found_n and found_char you could use one variable for all of 
> them, and if you did so...
That's what I can't see; I have no idea how to use only one 
variable if I need to find either CR or LF at the end of the line.
How can that be only one variable?
> >     if ( ((found_r = strchr(buffer, newline_r)) != NULL)
> >         || ((found_n = strchr(buffer, newline_n)) != NULL) )
> >     {
> ...the next statement would not be needed
> >         found_char = (found_r) ? found_r : found_n;
> >         *index = found_char - buffer;
> >
> >         if(buffer == found_char)
> >         {
> >             printf("Buffer is empty; please, check the input data\n");
> >             return false;
> >         }
> >         *found_char = '\0';
> >
> >         return true;
> >     }
> Here is the bug: if buffer has no CR/LF, then 'index' is not set.
> Since you used 4 variables to represent the line terminator, it is no 
> surprise that you missed to ensure that one of them was properly set. 
It is not the amount of variable I used that caused this mistake; it is a pure
mistake, no excuses based on excess of variables; functions can have 
many many variables, it doesn't mean that mistakes can be attribute
to that amount ) 
> Unfortunately it is the one that you are returning to the caller.
> >     return false;
> > }
> >

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


#100310

FromBarry Schwarz <schwarzb@dqel.com>
Date2016-12-26 14:38 -0800
Message-ID<6c536ct1dmnr1n72eco6el45lu3ft6bq52@4ax.com>
In reply to#100302
On Mon, 26 Dec 2016 10:39:30 -0800 (PST), Alla _
<modelling.data@gmail.com> wrote:

<snip>

> I missed the fact that I count the difference between two addresses, 
>and all addresses are zero based.
>Please, take a look at this version. Is it better? Have I correctly understood
>the notion of simplification?
>I have also added the part that deletes any unwanted trailing commas. 
>Is it better now?
>
>#include <stdio.h>
>#include <stdlib.h>
>#include <ctype.h>
>#include <string.h>
>#include <stdbool.h>
>
>#define BUFFER_SIZE 100
>#define INCOME_STATEMENT "../files/income_test.csv"
>
>bool get_line (FILE *input_file);
>bool unprintable(char *buffer);
>bool found_char(char *buffer, size_t *index, const char *newline);
>
>int main(int argc, char *argv[])
>{
>    //Check for correct number of arguments
>    if(argc > 2)
>    {
>        fputs("Sorry, the program processes only one file.\n", stderr);
>        return EXIT_FAILURE;
>    }
>    //Determine a file to use
>    const char *data_file = (argc == 2)? argv[1] : INCOME_STATEMENT;
>    
>    FILE *fp = fopen(data_file, "r");
>    
>    if ( fp )
>    {
>        if( !get_line(fp) )
>        {
>            puts("Reading csv file failed");
>            return EXIT_FAILURE;
>        }
>        fclose(fp);
>        return EXIT_SUCCESS;
>    }
>    //Couldn't open the file
>    else
>    {
>        perror(data_file);
>    }
>    return EXIT_FAILURE;
>}

You asked about simplification.  Consider
int main
     ...
     if (fp)
          if (get_line(fp))  <=========
               fclose(fp)
               return success
          else
               puts(read failed)
     else
          perror
     return failure

>/** Function to read and process the data
> from the file line by line
> **/
>
>bool get_line (FILE *input_file)
>{
>    char buffer[BUFFER_SIZE] = "";
>    size_t line = 0;
>    const char newline_r = '\r';
>    const char newline_n = '\n';
>    size_t index;
>    
>    //Read each line from the file, store in the buffer
>    while(fgets(buffer, sizeof(buffer), input_file) != NULL)
>    {
>        line++;
>        //DEBUG
>        puts("*****************************");
>        printf("Buffer beg:: %s\n", buffer);
>        
>        //If CR is found, its index is less than LF index
>        if (found_char(buffer, &index, &newline_r))
>        {
>            buffer[index] = '\0';
>            //DEBUG
>            printf("CR found; buffer ends at [%li]:: %s\n", index, buffer);

%li is not the correct format for printing a size_t.

>        }
>        else if (found_char(buffer, &index, &newline_n))
>        {
>            buffer[index] = '\0';
>            //DEBUG
>            printf("LF found; buffer ends at [%li]:: %s\n", index, buffer);
>        }
>        
>        //Delete any trailing commas
>        if(buffer[index-1] == ',')
>        {
>            index--;
>            while(!isdigit(buffer[index]) && buffer[index] == ',')

You asked about simplification.  For what value of buffer[index] does
the first expression contribute anything?  In other words, if you
removed the call to isdigit, would the value of the while expression
ever be any different?

Are you not concerned about trailing blanks?

>                index--;
>            buffer[index+1] = '\0';
>            //DEBUG
>            printf("Comma found; buffer ends at [%li]:: %s\n", index+1, buffer);
>        }
>        //Check for any other unprintable characters
>        if(unprintable(buffer))
>        {
>            puts("CSV file contains unprintable characters");
>            puts("Please, correct the file and try again");
>            return false;
>        }
>    }
>    
>    if (ferror(input_file))
>    {
>        puts("Something went wrong with the provided file\n");
>        return false;
>    }
>    return true;
>}
>
>/** Find unprintable characters in array
>    other than LF and CR
> **/
>bool unprintable(char *buffer)
>{
>    while(*buffer != '\0')
>    {
>        if(!isprint(*buffer))
>            return true;
>        buffer++;
>    }
>    return false;
>}
>
>/** Find CR at the end of the line **/
>bool found_char(char *buffer, size_t *index, const char *newline)

You asked about simplification.  Why are you passing newline as a
pointer?  You never assign anything to *newline.  Your only use of
newline is with the dereference operator.  You could pass the
character directly since that is the only value your program is
interested in.

>{
>    char *found = strchr(buffer, *newline);
>    if(found != NULL)
>    {
>        *index = found - buffer;
>        //DEBUG
>        printf("found %p, buffer %p\n", (void*)found, (void *) buffer);
>        printf("index = %li\n", *index);
>        //If array is empty
>        if(*index == 0)
>        {
>            buffer[*index] = '\0';
>            printf("Buffer is empty; please, check the input data\n");
>            return false;
>        }
>        //DEBUG
>        buffer[*index] = '&';
>        printf("Buffer [%zu]:: %s\n", *index, buffer);
>        return true;
>    }
>    else
>        puts("The newline character is not found");
>    return false;
>}
>

-- 
Remove del for email

[toc] | [prev] | [standalone]


Page 13 of 13 — ← Prev page 1 … 11 12 [13]

Back to top | Article view | comp.lang.c


csiph-web