Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

asterisk in command line parameter converted to something else

 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing a program to take 3 command line parameters and perform simple arithmetic. The second parameter is either +, -, *, /, or %. They all work fine except for the asterisk. So if my command line parameters are 6 * 5, when I display all the arguments, it says I have 4 arguments:
args[0]: 6
args[1]: Calculator.class
args[2]: MathWorker.class
args[3]: 5

I am using those two classes... how can i tell my program to just accept an asterisk as an asterisk without it being converted into a list of the classes I'm using? Thanks.
 
Marshal
Posts: 24927
61
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your shell automatically expands * to be a list of files in the current directory. How you do that depends on what shell you are using. Since you didn't know this I will guess that it is the Windows command prompt. Try typing these two lines at the command line:

dir *
dir '*'

and you will see what I mean.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use double quotations around the asterix
 
Eric Daly
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I am using the Windows XP command prompt. So there is not a way to disable the automatic "globbing" (I heard it referred to) that the command prompt promptly commands itself to do? Thanks for the help.
 
F is for finger. Can you stick your finger in your nose? Doesn't that feel nice? Now try this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!