Thread: A little question about formatted input ..

  1. #1
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657

    A little question about formatted input ..

    Code:
    " [ %s , %s , %s , %s ] "
    How should I change this format string such that whitespaces between the strings and the commas become optional(/or not allowed, if that is simpler) ?
    ...just removing the spaces doesn't seem to work...

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Look into the %[] conversion specifier. It also depends on how your input actually is. It's sort of silly for "formatted input" to be flexible. That goes against the whole "formatted" thing. Use %s, if ',' is at the end, trim it.


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Accepting formatted input
    By fxtdr79 in forum C Programming
    Replies: 15
    Last Post: 06-28-2010, 01:25 PM
  2. Secure coding and formatted input
    By laserlight in forum C++ Programming
    Replies: 7
    Last Post: 12-16-2009, 10:33 PM
  3. Formatted input
    By vaibhav in forum C++ Programming
    Replies: 1
    Last Post: 10-21-2005, 11:19 PM
  4. Number input and formatted output
    By scoobasean in forum C++ Programming
    Replies: 4
    Last Post: 12-20-2004, 11:17 PM
  5. formatted file input
    By Flikm in forum C++ Programming
    Replies: 1
    Last Post: 04-09-2002, 10:12 PM