Semester : S1 and S2
Subject : Computer Programming
Year : 2017
Term : DECEMBER
Branch : BIOTECHNOLOGY
Scheme : 2015 Full Time
Course Code : CS 100
Page:44
else
printf("\nFile opened ");
}
fseek(fp, 0, 2); /* file pointer at the end of file */
size = ftell(fp); /* take a position of file
pointer un size variable */ printf("The
size of given file is : %d\n", size);
fclose(fp);
b) Explain the concept of Command Line Argument with the help of an example.
Command Line Argument
Command line argument is a parameter supplied to the program when it is
invoked. Command line argument is an important concept in C programming. It
is mostly used when you need to control your program from outside. command
line arguments are passed to main() method.
Syntax:
int main( int argc, char *argv[])
Here arge counts the number of arguments on the command line and argy[ |
is a pointer array which holds pointers of type char which points to the
arguments passed to the program.
Example for Command Line Argument
#include
char "ദ്വി )
{
int i; if( argc
>=2)
{
printf("The
arguments
supplied are:\n");
for(i=1;i< argc;i++)
{
printf("%s\t" argv[i]);
}