Considering white spaces in search patterns

Discussion in 'C Programming' started by royzlife@gmail.com, Aug 22, 2007.

  1. Guest

    Hi,

    I am running a command like the one given below through a process:

    abc d:\myfolder\xyz_%s.*.log . -> now the %s puts a string which may
    or may not contain white spaces...
    e,g abc d:\myfolder\xyz_EARTH LIFE.*.log
    how should i confirm that that the entire string should be taken into
    consideration along with the white space in between to run the command
    abc on the file xyz_EARTH LIFE.123.log?

    Please help....
    , Aug 22, 2007
    #1
    1. Advertising

  2. Jack Klein Guest

    On Tue, 21 Aug 2007 22:42:24 -0700, wrote in
    comp.lang.c:

    > Hi,
    >
    > I am running a command like the one given below through a process:


    What's a process? Do you mean a C program? Are you passing a string
    to the system() function?

    > abc d:\myfolder\xyz_%s.*.log . -> now the %s puts a string which may
    > or may not contain white spaces...
    > e,g abc d:\myfolder\xyz_EARTH LIFE.*.log
    > how should i confirm that that the entire string should be taken into
    > consideration along with the white space in between to run the command
    > abc on the file xyz_EARTH LIFE.123.log?
    >
    > Please help....


    If you are using the standard C function system(), it depends on your
    system's command interpreter or shell, as this is what will actually
    parse the string.

    If a file name that you pass to the system function might contain
    spaces, your shell might need you to quote it. So instead of:

    sprintf(buffer, "abc %s", file_name_that_might_contain_spaces);

    ....you might try:

    sprintf(buffer, "abc \"%s\", file_name_that_might_contain_spaces);

    If that does not work for you, or you are using some method other than
    the standard C library system() function, post in a group that
    supports your particular platform.

    --
    Jack Klein
    Home: http://JK-Technology.Com
    FAQs for
    comp.lang.c http://c-faq.com/
    comp.lang.c++ http://www.parashift.com/c -faq-lite/
    alt.comp.lang.learn.c-c++
    http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
    Jack Klein, Aug 22, 2007
    #2
    1. Advertising

  3. Richard Bos Guest

    wrote:

    > I am running a command like the one given below through a process:
    >
    > abc d:\myfolder\xyz_%s.*.log . -> now the %s puts a string which may
    > or may not contain white spaces...
    > e,g abc d:\myfolder\xyz_EARTH LIFE.*.log
    > how should i confirm that that the entire string should be taken into
    > consideration along with the white space in between to run the command
    > abc on the file xyz_EARTH LIFE.123.log?


    What on earth made you conceive that this could possible be a C
    question? How command lines are parsed is up to the shell, not up to any
    individual C program. IOW: read your shell's manual, or ask in a
    newsgroup which handles MS Windows command.com.

    Richard
    Richard Bos, Aug 22, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. \Dandy\ Randy
    Replies:
    2
    Views:
    1,529
    Eric J. Roode
    Jul 21, 2003
  2. Prince

    Validation White Spaces

    Prince, Nov 2, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    975
    Peter Blum
    Nov 3, 2004
  3. Niels Dybdahl

    Color.white vs. Color.WHITE

    Niels Dybdahl, Oct 6, 2004, in forum: Java
    Replies:
    3
    Views:
    426
    Chris Smith
    Oct 6, 2004
  4. crichmon
    Replies:
    4
    Views:
    471
    Mabden
    Jul 7, 2004
  5. Ben C
    Replies:
    6
    Views:
    2,136
    Leif K-Brooks
    Jan 28, 2007
Loading...

Share This Page