Archived

This topic is now archived and is closed to further replies.

Why am I so damn stupid?

This topic is 6279 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

LOL. I''ve been teaching myself VC++ by writting a lil''SpaceWar proggy. The game is pure Win32, but I built a front end to allow the players to change different options using MFC. I had assumed I would be able to figure out how to send these selections to the game as a command line. HA! All the help files I can find on "command line" concern the VC compiler command line, not building and testing programs that accept a command line. So I have two questions that maybe someone can help me with: 1. How does one pass a command line to a debug build of a program (so that I can pass a command line, then stop execution at breakpoints to make sure my code is working right). I couldn''t figure it out. 2. How does one set up a program to accept a command line? I tried running my program in the "run" selection on the Start menu like this: "d:/C++ Stuff/Spacewar.exe \1 \2 \b" and like this "d:/C++ Stuff/Spacewar.exe -1 -2 -b" but all I got was "file not found" :-( 3. Parsing a command line is hard too, isn''t it? crap. Thanks for any input ----------------------------- Let be be finale of seem, seems to me.

Share this post


Link to post
Share on other sites
I don''t know about picking up command-line parameters, but to send them you need to make sure that the parameters are outside the "''s, not inside.
Thus, it should be:
"d:\C++ Stuff\Spacewar.exe" -1 -2 -b
rather than
"d:\C++ Stuff\Spacewar.exe -1 -2 -b"

-Neophyte


- Death awaits you all with nasty, big, pointy teeth. -

Share this post


Link to post
Share on other sites
Well, I dont know why you're so stupid BUT:



int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{



The lpCmdLine is a pointer to a string containing all characters from the command line. This is in a standard win32 prog.

For MFC there is a member variable called m_lpCmdLine within the CWinApp class containing the same info as lpCmdLine.

As to parsing them just use a bunch of those C string manipulators or as you're using MFC those nifty CString functions.

Hope i helped...

Edited by - jumble on October 8, 2000 6:46:35 PM

Share this post


Link to post
Share on other sites
Great! Those three comments told me exactly what I needed to make it work. Thanks a lot! Maybe I can finish tonight...

-----------------------------
Let be be finale of seem, seems to me.

Share this post


Link to post
Share on other sites