Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

help on command line

Posted on 2000-03-08
5
164 Views
Last Modified: 2010-04-15
i wnat to reed two filenames a letter and two numbers off the command line, the file names i can get, but am unsure how to convert argv[3] which is a char on the command line ie E or D and i wnat tio be able to do an if on themm but i am unable to say if argv[3]='E' which i want to i also need to be able to say 10*argv[4] which is the first number
0
Comment
Question by:kplonk
5 Comments
 
LVL 4

Accepted Solution

by:
abancroft earned 10 total points
ID: 2597055
There are several C runtime functions to convert strings to numbers.

To convert string to int: atoi().
To convert string to double: atof().

e.g. (assuming integers)
if (argv[3]=='E')
  myint = 10 * atoi(argv[4]);
0
 

Expert Comment

by:smartino
ID: 2597766
try to use getopts. It is much more versatile in parsing command line arguments. Check the man page.
0
 
LVL 84

Expert Comment

by:ozo
ID: 2597825
if( argv[3][0]=='E' )
0
 

Expert Comment

by:hernani
ID: 2598262
Form the above comments you can assemble the correct answer:

int my_int = 0;

if(argv[3][0]=='E') {
  my_int = 10 * atoi(argv[4]);
}
0
 

Author Comment

by:kplonk
ID: 2598483
thanks for that
0

Featured Post

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How do I test for current date? 9 109
Why does module make constant click noise ? 9 135
chcp 65001 File encoding 66 267
Resolve Dependency Issues 4 79
Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question