TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: VICTOR KEMP
from: THOMAS HABETS
date: 1998-01-05 12:46:00
subject: How do you read command line parameters?12:46:4901/05/98

 VK> Well the subject says it all.
Congratulations, I think you'll get about a thousand replies on this one.
instead of:
int main(void)
you write:
int main(int argc, char **argv)
I hope you define main as int, or else you are evil.
The command line is broken up into every word (with null termination) and put 
into argv[], with the program name in argv[0].
If more than one word is typed in quotes, it is still considered one word.
Quotation mark is typed in as \".
C:\FOO\>BAR -mmmm /bop "hanson sucks" beep\"beep
argc = 5
argv[0] = BAR    (or BAR.EXE or C:\FOO\BAR.EXE or similar. Depends on 
compiler)
argv[1] = -mmmm
argv[2] = /bop
argv[3] = hanson sucks
argv[4] = beep"beep
for (c = 1; c < argc; c++)
  ProcessCommandLine(argv[c]);
---
---------------
* Origin: Is it morning already? (2:201/293.22)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.