me again
how can i use command line arguments if i am not using comand line when opening my programs
and if i cant, how do i use command line to open them (in xp)
thanx in advance
me again
how can i use command line arguments if i am not using comand line when opening my programs
and if i cant, how do i use command line to open them (in xp)
thanx in advance
In console, the main's argv contains the arguments and argc the number of arguments. In Win32 subsystem the lpCmdLine argument of WinMain points to the command line arguments or alternatively you can use GetCommandLine() to get the command line string pointer.
"The Internet treats censorship as damage and routes around it." - John Gilmore
well
i am not that knowledgeable about command line
can you explain it with more detail
and how do i use GetCommandLine() function?
thanx
So, it returns a string containing the commandline - as easy as that.Code:LPTSTR GetCommandLine(VOID);
--
Mats
but i want to use argv and argc in my program
can i use these as main(argc, *argv[]) with
Code:
LPTSTR GetCommandLine(VOID); this and how?
thanx matsp
you are the man
Last edited by benhaldor; 08-20-2007 at 02:43 PM.
well actually these didnt solve my problems
any other suggestions?
What are you actually trying to do? What part of the usage of the command line arguments are you having problems with.
The basic principle is: if your application is a console application, the "main(int argc, char **argv)" method works, whether it was started from a command-line or using any other method to start the application. If your application is a windows application, then the "GetCommandLine" function is the option of choice for most cases.
Describe more of what you want to know, and someone will be able to help you, I can assure you.
--
Mats
Try using a batch file or create a program which uses ShellExecute() or ShellExecuteEx().
i am not using console and i want to learn GetCommandLine thing but nobody explained how it works
you said it gets the string from the command line but i want to use this main(int argc, char **argv) but not use the command line
from what i understand there is no way to do that
right?
The only purpose of int main(int argc, char *argv[]) is to retrieve command line arguments. If you don't want to use the command line, then this will be of little use.
GetCommandLine() is a less portable (Windows-only), and it gives you the whole command line, rather than each argument by itself. That is, with a command line of "program.exe some more text", argv[] will contain "program.exe", "some", "more", and "text", while GetCommandLine() would return exactly what you typed, "program.exe some more text". (I think; it may exclude the program's name. I've never actually used it.)
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
I posted how it works - what is missing from this, or what don't you understand about it?
This is not clear to me what you actually want to do - do you want to take the input commandline and split it in an "argc, argv" style? Or something else?you said it gets the string from the command line but i want to use this main(int argc, char **argv) but not use the command line
from what i understand there is no way to do that
right?
I'm 100% sure that if you clearly state what your goal is, and by this I mean, not just "I want to understand how to use X", but somthing like "I want to be able to use file(s) as argument(s) to my application, and load the file(s) given as commandline arguments".
--
Mats
In other words:
http://catb.org/~esr/faqs/smart-questions.html#goal
I suggest the OP reads the rest of the article, too.