query regarding wild card operation - Programmer

This is a discussion on query regarding wild card operation - Programmer ; Hello Can you please tell me how the wild card expansion is done in windows machine. For Example, if "test" is the executable and there are 1.prf, 2.prf and 3.prf in the current directory. Test.exe is executable from c source ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: query regarding wild card operation

  1. query regarding wild card operation

    Hello

    Can you please tell me how the wild card expansion is done in windows
    machine.

    For Example, if "test" is the executable and there are 1.prf, 2.prf
    and 3.prf in the current directory. Test.exe is executable from c
    source code.

    Then it should expand in main(argc , argv[]) as follows :

    ../test -v *.prf

    Argv[0] =test.exe

    Argv[1]= -v

    Argv[2] = 1.prf

    Argv[3] = 2.prf

    Argv[4] = 3.prf

    In Solaris platform it will be expanded as shown above but in windows
    it will just take as

    D:\test.exe -v *.prf

    Argv[0]= test.exe

    Argv[1] = -v

    Argv[2] = *.prf

    Is there any method where we can expand wild card in windows machine as
    shown for Solaris machine

    Thanks for any help.

    Regards.


  2. Re: query regarding wild card operation

    developer28 wrote:
    > Hello
    >
    > Can you please tell me how the wild card expansion is done in windows
    > machine.
    >
    > For Example, if "test" is the executable and there are 1.prf, 2.prf
    > and 3.prf in the current directory. Test.exe is executable from c
    > source code.
    >
    > Then it should expand in main(argc , argv[]) as follows :
    >
    > ./test -v *.prf
    >
    > Argv[0] =test.exe
    >
    > Argv[1]= -v
    >
    > Argv[2] = 1.prf
    >
    > Argv[3] = 2.prf
    >
    > Argv[4] = 3.prf
    >
    > In Solaris platform it will be expanded as shown above but in windows
    > it will just take as
    >
    > D:\test.exe -v *.prf
    >
    > Argv[0]= test.exe
    >
    > Argv[1] = -v
    >
    > Argv[2] = *.prf
    >
    > Is there any method where we can expand wild card in windows machine as
    > shown for Solaris machine
    >
    > Thanks for any help.
    >
    > Regards.
    >

    The is a significant difference between Unix and Windows with respect to
    the handling of wild cards on the command line.

    In Unix, the shell is responsible of expanding wild cards. Generally,
    anything that looks like a wild card will be expanded by the shell (if
    there are any file names which match the wild card) and the resulting
    list of file names will be passed to the application as argv[n],
    argv[n+1], argv[n+2], etc.

    In Windows, the shell does none of this. It simply passes the command
    line unchanged, except for environment variable replacement and removal
    of file redirections, to the application. The start up routine from the
    C run-time library provided with the compiler (often named CRT0.obj)
    parses the command line into white-space delimited fields and passes
    those fields as argv[n], argv[n+1], etc. Some compiler vendors,
    including Microsoft, provide an alternate version of CRT0.obj which,
    after parsing the command line, attempts to expand wild cards. (See your
    compiler documentation to find whether this alternate version is available.)

    There are advantages and disadvantages to both schemes. The major
    advantage of the Unix system is that applications don't have to worry
    about wild card expansion. (The same is true if you use the alternate
    start up routine.) On the other hand, if a Windows application uses the
    standard start up routine, it can do wild card expansion itself on only
    those arguments where it is appropriate.

    For example, suppose you wrote a command line calculator program. If it
    was run on Unix, a command like "calc a*b" might cause wild card
    expansion and a list of file names would be passed to the program
    instead of a multiplication expression. In Windows, the program would
    receive "a*b" and would be able to parse it as an expression.

    Norm

    --
    --
    To reply, change domain to an adult feline.


  3. Re: query regarding wild card operation



    On Jan 24, 9:40 am, Norman Bullen
    wrote:
    > developer28 wrote:
    > > Hello

    >
    > > Can you please tell me how the wild card expansion is done in windows
    > > machine.

    >
    > > For Example, if "test" is the executable and there are 1.prf, 2.prf
    > > and 3.prf in the current directory. Test.exe is executable from c
    > > source code.

    >
    > > Then it should expand in main(argc , argv[]) as follows :

    >
    > > ./test -v *.prf

    >
    > > Argv[0] =test.exe

    >
    > > Argv[1]= -v

    >
    > > Argv[2] = 1.prf

    >
    > > Argv[3] = 2.prf

    >
    > > Argv[4] = 3.prf

    >
    > > In Solaris platform it will be expanded as shown above but in windows
    > > it will just take as

    >
    > > D:\test.exe -v *.prf

    >
    > > Argv[0]= test.exe

    >
    > > Argv[1] = -v

    >
    > > Argv[2] = *.prf

    >
    > > Is there any method where we can expand wild card in windows machine as
    > > shown for Solaris machine

    >
    > > Thanks for any help.

    >
    > > Regards.The is a significant difference between Unix and Windows with respect to

    > the handling of wild cards on the command line.
    >
    > In Unix, the shell is responsible of expanding wild cards. Generally,
    > anything that looks like a wild card will be expanded by the shell (if
    > there are any file names which match the wild card) and the resulting
    > list of file names will be passed to the application as argv[n],
    > argv[n+1], argv[n+2], etc.
    >
    > In Windows, the shell does none of this. It simply passes the command
    > line unchanged, except for environment variable replacement and removal
    > of file redirections, to the application. The start up routine from the
    > C run-time library provided with the compiler (often named CRT0.obj)
    > parses the command line into white-space delimited fields and passes
    > those fields as argv[n], argv[n+1], etc. Some compiler vendors,
    > including Microsoft, provide an alternate version of CRT0.obj which,
    > after parsing the command line, attempts to expand wild cards. (See your
    > compiler documentation to find whether this alternate version is available.)
    >
    > There are advantages and disadvantages to both schemes. The major
    > advantage of the Unix system is that applications don't have to worry
    > about wild card expansion. (The same is true if you use the alternate
    > start up routine.) On the other hand, if a Windows application uses the
    > standard start up routine, it can do wild card expansion itself on only
    > those arguments where it is appropriate.
    >
    > For example, suppose you wrote a command line calculator program. If it
    > was run on Unix, a command like "calc a*b" might cause wild card
    > expansion and a list of file names would be passed to the program
    > instead of a multiplication expression. In Windows, the program would
    > receive "a*b" and would be able to parse it as an expression.
    >
    > Norm
    >
    > --
    > --
    > To reply, change domain to an adult feline.



    Hey Norm,

    Thanks for the help. But what i actually wanna know is that , incase my
    compiler does not support the version of CRT0.obj which helps me to do
    wild card expansions, is there some other way i can enable that.

    I read somewhere that this variable int _CRT_glob = 1 when declared can
    help..but don't know anything about it.

    If you know some way please suggest coz right now it is really very
    important for me.

    Thanks again.

    Regards.


  4. Re: query regarding wild card operation

    "developer28" wrote

    > Thanks for the help. But what i actually wanna know is that, in case my
    > compiler does not support the version of CRT0.obj which helps me to do
    > wild card expansions, is there some other way I can enable that.


    Not as a built-in part of the operating system. If your compiler doesn't
    provide it, you'll have to write it yourself. Ways of doing so include
    using the FindFirst and FindNext functions.

    > I read somewhere that this variable int _CRT_glob = 1 when declared can
    > help..but don't know anything about it.


    That's a fragment of C, and looks as if it's intended to provide a different
    way for startup code to tell if the program wants wildcards converted to
    filenames. Different from using a specific set of startup code, that is. It
    certainly isn't something that all compilers will necessarily provide.

    You Need To Look At Your Compiler's Documentation.

    John



+ Reply to Thread