Sponsored Content
Top Forums Programming Reading long options in C++ program Post 302611867 by kristinu on Friday 23rd of March 2012 04:38:25 PM
Old 03-23-2012
Reading long options in C++ program

I am reading arguments passed to a C++ program which accepts long options.

Long options start with '--', with the value joined with the option by an = sign, with no intervening spaces.

An example is as follows:

Code:
programName --vdz=15.0

I want to store 'vdz' in variable 'key', whereas 15.0 is stored in variable 'value'.

However I also need to find the character string starting from the first occurance of '='. I call it 'after'. Then assign 'value' by going to the second character position onward.

Code is as follows:
Code:
const char* after = strchr(argv[i], '=');
if (after != NULL) const char* value = after + 1;

Well, 'after' can be viewed as the value I want. Thus I am wondering whether I can assign 'value' immediately, or come up with a better descriptive variable name than 'after'.

Any suggestions?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

reading long filenames from nero to AIX

One of my colleagues is having an issue moving files between a windows box and the AIX servers in the office. The filenames are being truncated though i don't know to what extent. He's using Nero to burn the CD and I think he mentioned he's using Joliet. I found another thread that shows a... (1 Reply)
Discussion started by: categoryzd
1 Replies

2. Shell Programming and Scripting

Help with shell script to run the commands reading options from local file

I have to use shell script to run series of commands on another unix box by connecting through SSH and giving user credentials. For running commands on remote machine I have to use options reading from a local file. Process: Connecting to remote unix server <host1.ibm.com> through ssh Login: ... (2 Replies)
Discussion started by: itsprout
2 Replies

3. Shell Programming and Scripting

using getopt for both short and long options

Hi , I am using getopt for both short and long options as below SHORTOPTS="a:c" LONGOPTS="alpha:,charlie" OPTS=$(getopt -o $SHORTOPTS --longoptions $LONGOPTS -n "$progname" -- "$@") eval set -- "$OPTS" while ; do case $1 in -a|--alpha) echo "-a or --alpha... (0 Replies)
Discussion started by: padmisri
0 Replies

4. Shell Programming and Scripting

using getopt for both short and long options

Hi , I am using getopt for both short and long options as below SHORTOPTS="a:c" LONGOPTS="alpha:,charlie" OPTS=$(getopt -o $SHORTOPTS --longoptions $LONGOPTS -n "$progname" -- "$@") eval set -- "$OPTS" while ; do case $1 in -a|--alpha) echo "-a or --alpha... (1 Reply)
Discussion started by: padmisri
1 Replies

5. Shell Programming and Scripting

using getopt for both short and long options

Hi , I am using getopt for both short and long options as below SHORTOPTS="a:c" LONGOPTS="alpha:,charlie" OPTS=$(getopt -o $SHORTOPTS --longoptions $LONGOPTS -n "$progname" -- "$@") eval set -- "$OPTS" while ; do case $1 in -a|--alpha) echo "-a or --alpha... (1 Reply)
Discussion started by: padmisri
1 Replies

6. Shell Programming and Scripting

Reading command options one by one

Hi, Just some questions on the script below...? Given: bash-2.03$ command -a option1 name1 name2 ParseOptions() { local Len=${#@} local Ctr=2 #always start at 2 local Name=() local Iter=0 while ; do if <- Is this correct? so I can get the $2... (2 Replies)
Discussion started by: h0ujun
2 Replies

7. Shell Programming and Scripting

Reading command line options from bash script

I have the following code and I am calling it using ./raytrac.bash -u and getting problems. For some reason opt_usage is still 0. opt_usage=0 iarg=0 narg=$# while (($iarg < $narg)) do (( iarg = $iarg + 1 )) arg=$argv usrInputFlag=`echo $arg | awk '/=/ {print 1}; ! /=/... (22 Replies)
Discussion started by: kristinu
22 Replies

8. Shell Programming and Scripting

How to display a message if program hangs(takes too long)

I have a ksh script (script1) that calls another ksh script (script2). If script2.ksh hangs or takes too long to execute I want script1.ksh to kill the call to script2.ksh and instead just display "Script2 can't run right now". Could someone help me with coding this? (1 Reply)
Discussion started by: mrskittles99
1 Replies

9. Shell Programming and Scripting

Perl :: Getopt::Long in the program

While going through some of the perl script... I had found the below line.. use Getopt::Long; my $GetOptionsReturnCode = GetOptions ( '<>' => sub { push(@unknownArg, @_); }, 'h|help' => sub { &helpMessage(); exit 0; }, ); Could anyone please explain the above one ... (1 Reply)
Discussion started by: scriptscript
1 Replies

10. Shell Programming and Scripting

Reading a long literal continued next line

I am trying to identify all messages or prompts from a number of COBOL programs and they can usually be identified by a pair of double quotes on one line. However, sometimes the literal will not be finished on the first line but after a dash in column 7 of the next line, the literal will be... (6 Replies)
Discussion started by: wbport
6 Replies
QUAKE-SERVER(6) 						   Games Manual 						   QUAKE-SERVER(6)

NAME
quake-server - dedicated server for Quake SYNOPSIS
quake-server [WRAPPER-OPTIONS] [ENGINE-OPTIONS] [ENGINE-COMMANDS]... DESCRIPTION
This manual page documents briefly the quake-server command. Quake is a popular first-person shooter game that appeared in 1996, released by iD Software. This wrapper script will launch the Quake dedicated server. The game data needs to be installed independently using the 'game-data-packager' program, and by default it will be looked for at /usr/share/games/quake. This wrapper script accepts the two common GNU-style options to get information on the program. Any further arguments are passed to the engine unmodified. Consult the engine documentation for full details, but most engines support a syntax whereby engine switches are pre- fixed with a minus sign, and you can give console commands by prefixing with a plus sign. See the examples section for some common cases. OPTIONS
These options are accepted for WRAPPER-OPTIONS in the synopsis. -h, --help Show summary of options. -v, --version Show version of program. SEE ALSO
quake(6), quakespasm(6), game-data-packager(6). AUTHOR
This manual page, and the Quake wrapper script, were written by David Banks and Simon McVittie for the Debian project (and may be used by others). 2011-06-22 QUAKE-SERVER(6)
All times are GMT -4. The time now is 05:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy