answersLogoWhite

0


Best Answer

IN C++

#include <iostream> int main(int argc, char *argv[]) { using namespace std; cout << "There are " << argc << " arguments:" << endl; // Loop through each argument and print its number and value for (int nArg=0; nArg < argc; nArg++) cout << nArg << " " << argv[nArg] << endl; return 0; }

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

The main method in Java has a string array parameter that contains the arguments passed in.

Example:

import java.util.Arrays;

public class A {

public static void main(String[] args){System.out.println(Arrays.toString(args));}

}

...

>java A "Hello World"

[Hello World]

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program which uses Command Line Arguments?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is java command?

A Java application can accept any number of arguments from the command line. This allows the user to specify configuration information when the application is launched.The user enters command-line arguments when invoking the application and specifies them after the name of the class to be run.


Can a Java program use one or more command line arguments?

Command line arguments in Java are, as with most programming languages, a way to give information to a program at the point of invoking (starting to run) that program. The information is given in the form of a text string. Command line arguments are accessible in a Java program as an array of String objects passed into the program's "main" method. Unlike some programming languages (such as C/C++), where the command used to invoke the program is passed into the first array location (index 0) and the arguments subsequently, in Java the first argument occupies index 0. Command line arguments are a useful way of gathering information from the user when it is likely will know the information at the start of the program. For example, a Java application might copy a file from myFile.txt to myNewFile.txt by running the command "java CopyUtil myFile.txt myNewFile.txt". It is useful to allow such information to be passed in via command line arguments to make the program more scriptable: in other words, more conducive to scripted invocation, through a Desktop shortcut, through a batch file, through a shell script, etc.


How do you pass command line arguments using turbo in c compiler?

In the Options menu the Arguments command.


What is a command argument?

Command line arguments are provided at the time of running the program. Example: Suppose that your program needs input name and its value then running it from commandline(DOS prompt) you provide the values after the program name java xyz name JAX(name is name and value is jax)


Write a programme to perform binary operations on integer argument The arguments and operators should be accepted using command line parameters?

There are many different operators, which are you referring to?

Related questions

What is java command?

A Java application can accept any number of arguments from the command line. This allows the user to specify configuration information when the application is launched.The user enters command-line arguments when invoking the application and specifies them after the name of the class to be run.


Can a Java program use one or more command line arguments?

Command line arguments in Java are, as with most programming languages, a way to give information to a program at the point of invoking (starting to run) that program. The information is given in the form of a text string. Command line arguments are accessible in a Java program as an array of String objects passed into the program's "main" method. Unlike some programming languages (such as C/C++), where the command used to invoke the program is passed into the first array location (index 0) and the arguments subsequently, in Java the first argument occupies index 0. Command line arguments are a useful way of gathering information from the user when it is likely will know the information at the start of the program. For example, a Java application might copy a file from myFile.txt to myNewFile.txt by running the command "java CopyUtil myFile.txt myNewFile.txt". It is useful to allow such information to be passed in via command line arguments to make the program more scriptable: in other words, more conducive to scripted invocation, through a Desktop shortcut, through a batch file, through a shell script, etc.


How do you pass command line arguments using turbo in c compiler?

In the Options menu the Arguments command.


How do you write a function in Turbo C that can run the program without rerunning the whole program?

The execution path of a program can only be affected by the program input. That is, if you change the input, you can alter the way the program behaves (just as changing the arguments to a function can alter the behaviour of the function). Typically you will alter the input via the command line, but you can also alter the input at any time during program execution. Redirecting input via the command line can be achieved by extracting the input from a file (via std::cin) or by implementing command line switches in your main function, or through a combination of the two.


Which Windows program is used to set file attributes?

It isn't exactly a Windows program, but the Microsoft utility that's used to edit file attributes is ATTRIB.EXE. It's run at the command line. For it's arguments type attrib /? at the command line or visit the related link below.


When you write a program that will run in a GUI environment as opposed to a command line environment?

Some syntax is different.


Definition of commandline arguments?

Hii I am Ajay Kumar MCA Student A Java application can accept any number of arguments from the command line. The user enters command-line arguments when invoking the application and specifies them after the name of the class to be run.


How do you write a program using command line arguments?

#include&lt;stdio.h&gt; int main( int argc, char *argv[]) { FILE *p; if(!argv[1]) { printf("can't open the file"); } else p=fopen("venki.txt","r" ); return 0; }


How do you give command line arguments while running a program in Linux?

Different commands can have different syntaxes. The most common format is 'command -a -b -c -d' or 'command -abcd'. Commands with long options will also support the syntax 'command --option --option2 --coption3'.


What is a command argument?

Command line arguments are provided at the time of running the program. Example: Suppose that your program needs input name and its value then running it from commandline(DOS prompt) you provide the values after the program name java xyz name JAX(name is name and value is jax)


Write a programme to perform binary operations on integer argument The arguments and operators should be accepted using command line parameters?

There are many different operators, which are you referring to?


Command line argument?

Command line argument is a value that is passed to a program whenever the program is executed. It is used to avoid hard coding.