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


Groups > comp.lang.c > #149335

Re: Scanf and Comma Delimiter

From Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups comp.lang.c
Subject Re: Scanf and Comma Delimiter
Date 2020-01-21 23:15 -0800
Organization None to speak of
Message-ID <878sm07yhf.fsf@nosuchdomain.example.com> (permalink)
References <r07n7p0d1d@news3.newsguy.com> <862fced3-1e1e-4d88-951f-eb06bfa89fb3@googlegroups.com> <r07u6601n8b@news1.newsguy.com>

Show all headers | View raw


F Russell <fr@random.info> writes:
> On Tue, 21 Jan 2020 13:43:27 -0800, Malcolm McLean wrote:
>> It does.
>> int a,b;
>> scanf(%d, %d\n", &x, &b);
>> 
>> will read two comma-delimited values into a and b.
>> 
>
> That won't work for strings:
>
> fscanf(fd, "%s,%s\n", string1, string2);

That won't work for strings either.  If the input is "foo bar,baz",
it will fail; the first "%s" will match "foo" and it will then fail
looking for a comma.

(I'm taking a risk by posting this without trying it.)

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Scanf and Comma Delimiter F Russell <fr@random.info> - 2020-01-21 20:34 +0000
  Re: Scanf and Comma Delimiter Bonita Montero <Bonita.Montero@gmail.com> - 2020-01-21 21:40 +0100
    Re: Scanf and Comma Delimiter chad <cdalten@gmail.com> - 2020-01-21 13:04 -0800
      Re: Scanf and Comma Delimiter Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-01-21 21:34 +0000
    Re: Scanf and Comma Delimiter Anton Shepelev <anton.txt@g{oogle}mail.com> - 2020-01-22 13:37 +0300
      Re: Scanf and Comma Delimiter gazelle@shell.xmission.com (Kenny McCormack) - 2020-01-22 11:46 +0000
        Re: Scanf and Comma Delimiter Anton Shepelev <anton.txt@g{oogle}mail.com> - 2020-01-22 15:25 +0300
        Re: Scanf and Comma Delimiter Bart <bc@freeuk.com> - 2020-01-22 14:02 +0000
          Re: Scanf and Comma Delimiter Bart <bc@freeuk.com> - 2020-01-22 20:13 +0000
      Re: Scanf and Comma Delimiter Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-01-22 15:00 +0000
      Re: Scanf and Comma Delimiter Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2020-01-29 11:10 -0500
  Re: Scanf and Comma Delimiter scott@slp53.sl.home (Scott Lurndal) - 2020-01-21 20:51 +0000
  Re: Scanf and Comma Delimiter Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-01-21 21:31 +0000
    Re: Scanf and Comma Delimiter James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-22 00:03 -0500
  Re: Scanf and Comma Delimiter Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-01-21 13:43 -0800
    Re: Scanf and Comma Delimiter F Russell <fr@random.info> - 2020-01-21 22:32 +0000
      Re: Scanf and Comma Delimiter richard@cogsci.ed.ac.uk (Richard Tobin) - 2020-01-21 23:20 +0000
      Re: Scanf and Comma Delimiter Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-21 23:15 -0800
  Re: Scanf and Comma Delimiter James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-22 00:30 -0500
  Re: Scanf and Comma Delimiter Andrey Tarasevich <andreytarasevich@hotmail.com> - 2020-01-22 11:45 -0800

csiph-web