answersLogoWhite

0

How do you write a program using command line arguments?

Updated: 8/16/2019
User Avatar

Wiki User

13y ago

Best Answer

#include<stdio.h>

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;

}

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write a program using command line arguments?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you write c file arguments?

Using parameters argc and argv, and library functions fopen, fprintf, fclose


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?


Write a c program for function with no arguments and no return values?

void mynullfunction () {;}


Write a sample program using ASPNET explaining all the syntax and semantics of the program?

write a sample program using asp.net explaining all the syntax and semantics of the program


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.


How do you write Square program using vb?

write a vb program to find the magic square


Write Client and server program in C language using UDP?

Write and run a client and a server program in C-language using UDP


How do you change the pre-recorded sound on something like the Staples Easy Button to different sound of your choice from the computer?

You would have to use a command script program, and write a program that could be programmed into the micro processing chip inside. Using a program like Visual Basic.


How do you write a c program to convert binary to decimal by using while statement?

write a c++ program to convert binary number to decimal number by using while statement


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

Some syntax is different.


How to write java program without using main method?

Java program without mainWe need a main method for executing a program.But YES we can write a program without using main() method.TRICK 1 of 2 :: while writing applets in java we don't use main... we use init() method instead.TRICK 2 of 2 :: using 'static' we can write a program whic will execute successfully and output the desired message on screen. Here it is :: class Mohit{ static { System.out.println("This java program has run without the main method"); System.exit(0); } } -->save the program as Mohit.java to compile::javac Mohit.java (in command prompt) to run ::java Mohit(command prompt) output will be ::This java program has run without the main methodWhoa!!!!! we are done.;)


How do you capture the output of C program in to another C program?

HIYou can first include the 1st program in ur 2nd program using # include and then whatever be the output from frst it can be used in second program.pankajThat's what popen is good for. Read the manual.