Thread overview
argv corrupted by long directory names
Aug 09, 2002
James
Aug 09, 2002
Jan Knepper
Aug 09, 2002
James
Aug 09, 2002
Jan Knepper
Aug 09, 2002
James
Aug 10, 2002
Walter
Aug 09, 2002
Keith Fuller
Aug 09, 2002
James
Aug 10, 2002
Jan Knepper
August 09, 2002
I'm passing arguments to the following Win32 console application:
     C:\Documents and Settings\James\My Documents\My
Stuff\Development\Test.exe

When I use the debugger to test this, instead of *argv[0] containing the
above file spec it contains the characters leading up to the first space.
So,
*argv[0] == "C:\Documents"
*argv[1] == "and"
*argv[2] == "Settings\James\My Documents\My"
....

Anyone know a solution to this ?

James


August 09, 2002
Have you tried putting it between quotes?
This way of passing arguments is what Win32 does.
A 'space' separates arguments...

"C:\Documents and Settings\James\My Documents\My Stuff\Development\Test.exe"

Jan



James wrote:

> I'm passing arguments to the following Win32 console application:
>      C:\Documents and Settings\James\My Documents\My
> Stuff\Development\Test.exe
>
> When I use the debugger to test this, instead of *argv[0] containing the
> above file spec it contains the characters leading up to the first space.
> So,
> *argv[0] == "C:\Documents"
> *argv[1] == "and"
> *argv[2] == "Settings\James\My Documents\My"
> ....
>
> Anyone know a solution to this ?
>
> James



August 09, 2002
I can't control what the first argument is and therefore can't put quotes
around it.
*argv[0] always contains the name and path of the executable.
User supplied arguments start at *argv[1].



"Jan Knepper" <jan@smartsoft.cc> wrote in message news:3D541F5E.218FE4C@smartsoft.cc...
> Have you tried putting it between quotes?
> This way of passing arguments is what Win32 does.
> A 'space' separates arguments...
>
> "C:\Documents and Settings\James\My Documents\My
Stuff\Development\Test.exe"
>
> Jan
>
>
>
> James wrote:
>
> > I'm passing arguments to the following Win32 console application:
> >      C:\Documents and Settings\James\My Documents\My
> > Stuff\Development\Test.exe
> >
> > When I use the debugger to test this, instead of *argv[0] containing the above file spec it contains the characters leading up to the first
space.
> > So,
> > *argv[0] == "C:\Documents"
> > *argv[1] == "and"
> > *argv[2] == "Settings\James\My Documents\My"
> > ....
> >
> > Anyone know a solution to this ?
> >
> > James
>
>
>


August 09, 2002
<g>
I guess you can not...
Sorry, I should have read better, I thought you were talking about > argv [ 0 ].

Anyways I tried the same thing and for me it seems to work just fine:

#include <stdio.h>

int  main ( int  argc, char  **argv )
{
   for ( int  i = 0 ; i < argc ; i++ )
      printf ( "'%s'\n", *( argv + i ) );

   return (  0 );
}


C:\Documents and Settings\JAK\Local Settings\Temp>test0149 test 'C:\Documents and Settings\JAK\Local Settings\Temp\Test0149.exe' 'test'

C:\Documents and Settings\JAK\Local Settings\Temp>test0149 test 'C:\Documents and Settings\JAK\Local Settings\Temp\Test0149.exe' 'test'

C:\Documents and Settings\JAK\Local Settings\Temp>cd\

C:\>"C:\Documents and Settings\JAK\Local Settings\Temp\Test0149.exe" 'C:\Documents and Settings\JAK\Local Settings\Temp\Test0149.exe'

C:\>

Are you sure you are targetting Win32?

Jan



James wrote:

> I can't control what the first argument is and therefore can't put quotes
> around it.
> *argv[0] always contains the name and path of the executable.
> User supplied arguments start at *argv[1].
>
> "Jan Knepper" <jan@smartsoft.cc> wrote in message news:3D541F5E.218FE4C@smartsoft.cc...
> > Have you tried putting it between quotes?
> > This way of passing arguments is what Win32 does.
> > A 'space' separates arguments...
> >
> > "C:\Documents and Settings\James\My Documents\My
> Stuff\Development\Test.exe"
> >
> > Jan
> >
> >
> >
> > James wrote:
> >
> > > I'm passing arguments to the following Win32 console application:
> > >      C:\Documents and Settings\James\My Documents\My
> > > Stuff\Development\Test.exe
> > >
> > > When I use the debugger to test this, instead of *argv[0] containing the above file spec it contains the characters leading up to the first
> space.
> > > So,
> > > *argv[0] == "C:\Documents"
> > > *argv[1] == "and"
> > > *argv[2] == "Settings\James\My Documents\My"
> > > ....
> > >
> > > Anyone know a solution to this ?
> > >
> > > James
> >
August 09, 2002
Jan

I actually made a slight mistake in my original description of the problem.
I'm passing 3 arguments to the IDDE Project->Arguments facility.
Writing all arguments received to the screen (enclosed in <>), I get:

argc is 9
arg 0 <C:\Documents and Settings\James\My Documents\My
Stuff\Development\Work Areas\MODFLNM\modflnm.EXE>
arg 1 <and>
arg 2 <Settings\James\My>
arg 3 <Documents\My>
arg 4 <Stuff\Development\Work>
arg 5 <Areas\MODFLNM\modflnm.EXE>
arg 6 <music>
arg 7 <wav>
arg 8 <mp3>


Running the same program from the command prompt, the output is:

argc is 4
arg 0 <C:\Documents and Settings\James\My Documents\My
Stuff\Development\Work Areas\MODFLNM\modflnm.EXE>
arg 1 <music>
arg 2 <wav>
arg 3 <mp3>

By the way, I'm running SCWMN32.EXE.

James




"Jan Knepper" <jan@smartsoft.cc> wrote in message news:3D5443F5.FFA66FDF@smartsoft.cc...
> <g>
> I guess you can not...
> Sorry, I should have read better, I thought you were talking about > argv
[ 0 ].
>
> Anyways I tried the same thing and for me it seems to work just fine:
>
> #include <stdio.h>
>
> int  main ( int  argc, char  **argv )
> {
>    for ( int  i = 0 ; i < argc ; i++ )
>       printf ( "'%s'\n", *( argv + i ) );
>
>    return (  0 );
> }
>
>
> C:\Documents and Settings\JAK\Local Settings\Temp>test0149 test 'C:\Documents and Settings\JAK\Local Settings\Temp\Test0149.exe' 'test'
>
> C:\Documents and Settings\JAK\Local Settings\Temp>test0149 test 'C:\Documents and Settings\JAK\Local Settings\Temp\Test0149.exe' 'test'
>
> C:\Documents and Settings\JAK\Local Settings\Temp>cd\
>
> C:\>"C:\Documents and Settings\JAK\Local Settings\Temp\Test0149.exe" 'C:\Documents and Settings\JAK\Local Settings\Temp\Test0149.exe'
>
> C:\>
>
> Are you sure you are targetting Win32?
>
> Jan
>
>
>
> James wrote:
>
> > I can't control what the first argument is and therefore can't put
quotes
> > around it.
> > *argv[0] always contains the name and path of the executable.
> > User supplied arguments start at *argv[1].
> >
> > "Jan Knepper" <jan@smartsoft.cc> wrote in message news:3D541F5E.218FE4C@smartsoft.cc...
> > > Have you tried putting it between quotes?
> > > This way of passing arguments is what Win32 does.
> > > A 'space' separates arguments...
> > >
> > > "C:\Documents and Settings\James\My Documents\My
> > Stuff\Development\Test.exe"
> > >
> > > Jan
> > >
> > >
> > >
> > > James wrote:
> > >
> > > > I'm passing arguments to the following Win32 console application:
> > > >      C:\Documents and Settings\James\My Documents\My
> > > > Stuff\Development\Test.exe
> > > >
> > > > When I use the debugger to test this, instead of *argv[0] containing
the
> > > > above file spec it contains the characters leading up to the first
> > space.
> > > > So,
> > > > *argv[0] == "C:\Documents"
> > > > *argv[1] == "and"
> > > > *argv[2] == "Settings\James\My Documents\My"
> > > > ....
> > > >
> > > > Anyone know a solution to this ?
> > > >
> > > > James
> > >


August 09, 2002
You can try using this API call to get the command line:

LPTSTR GetCommandLine(VOID);


In article <aj0uke$2i46$1@digitaldaemon.com>, James says...
>
>I'm passing arguments to the following Win32 console application:
>     C:\Documents and Settings\James\My Documents\My
>Stuff\Development\Test.exe
>
>When I use the debugger to test this, instead of *argv[0] containing the
>above file spec it contains the characters leading up to the first space.
>So,
>*argv[0] == "C:\Documents"
>*argv[1] == "and"
>*argv[2] == "Settings\James\My Documents\My"
>....
>
>Anyone know a solution to this ?
>
>James
>
>


August 09, 2002
Thanks.
I'm still at the very early stages of programming in this environment, so
API calls are still a little advanced for me.
I haven't started on c++ yet.
Thats's why I'm using the Win32 console.



"Keith Fuller" <Keith_member@pathlink.com> wrote in message news:aj1gpr$3ep$1@digitaldaemon.com...
> You can try using this API call to get the command line:
>
> LPTSTR GetCommandLine(VOID);
>
>
> In article <aj0uke$2i46$1@digitaldaemon.com>, James says...
> >
> >I'm passing arguments to the following Win32 console application:
> >     C:\Documents and Settings\James\My Documents\My
> >Stuff\Development\Test.exe
> >
> >When I use the debugger to test this, instead of *argv[0] containing the
> >above file spec it contains the characters leading up to the first space.
> >So,
> >*argv[0] == "C:\Documents"
> >*argv[1] == "and"
> >*argv[2] == "Settings\James\My Documents\My"
> >....
> >
> >Anyone know a solution to this ?
> >
> >James
> >
> >
>
>


August 10, 2002
Thanks for the clarification. The IDDE doesn't handle spaces in path names in general. I hope to get this fixed in the future, but for now we're stuck with that. Sorry.

"James" <ploppy.powell@virgin.net> wrote in message news:aj1gp6$3el$1@digitaldaemon.com...
> Jan
>
> I actually made a slight mistake in my original description of the
problem.
> I'm passing 3 arguments to the IDDE Project->Arguments facility. Writing all arguments received to the screen (enclosed in <>), I get:



August 10, 2002
James wrote:

> I haven't started on c++ yet.
> Thats's why I'm using the Win32 console.

<g> Those two are not related as such...
You can to C++ and Win32 Console.
You can do C and Win32 GUI
You can do C++ and Win32 GUI... and MFC.
Jan