What would you like to do?

How do you write a program using command line arguments?

already exists.

Would you like to merge this question into it?

already exists as an alternate of this question.

Would you like to make it the primary and merge this question into it?

exists and is an alternate of .

#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;
}
4 people found this useful
Thanks for the feedback!

How to write a program that accepts two file names as command line arguments?

  int main(int argc, char** argv) {   char *argument1, *argument2;   if (argc < 2) ...{exception}...   argument1 = argv[1];   argument2 = argv[2];   }  

Program to add two numbers using command line argument?

public class TwoNumbers { · public static void main(String args[]){ · · int first_number = Integer.parseInt(args[0]); · int second_number = Integer.parseInt(args[1]);

Program to copy one file into another using command line arguments?

include #include #include #include #include #include #include int main(int argc,char * argv[]) { int fp,ft,buffsize=10; char *buff=(char *)malloc(sizeof(ch

Write a program to echo the arguments given in the command line?

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(S

What is a command line argument and what is its use?

Back in the days of MSDOS, before Windows, programs were run not in a graphical shell but in a text-mode command-line environment. The name of the program was typed in, and th

How do you write a C program to reverse the first n characters in a file without using string handling functions and command line arguments?

include #include int main (void) { FILE* pf;. int i, j, count;. char file[255]; . char* buf; . while (true) { printf ("File name: "); scanf ("%s", file); if (pf=fopen (fi