Page 303 - DCAP404 _Object Oriented Programming
P. 303
Object-oriented Programming
Notes Then the output of the program would be as follows:
C:\>abc
delhi
agra
kolkata
As you must have noticed the parameter argc is initialized with the number of command line
arguments plus one. These command lines are stored in argv[1], argv[2]… The name of the
program is itself stored in argv[0]. It is up to the programmer to posses these command line
arguments the way they want.
Notes Please note that the command line arguments are always read as string of characters
even if a numeric value is passed as argument.
Another important fact to be noted is the argument names in the main function need not be argc
and argv alone. They can have any valid name as long as the type are int and char * respectively
as illustrated in the following code snippet.
#include <iostream.h>
void main(int a, char *ar[])
{
for (int i=0; i<a;i++)
cout<<’\n’<<ar[i];
}
Self Assessment
Fill in the blanks:
17. ……………………….. is initialized with a number of parameters provided in command
line.
Caselet Hardware and Software of Innovation
here is much that is dysfunctional in the US, but there is also a great deal to be
optimistic about, writes Adam Segal in Advantage: How American innovation can
Tovercome the Asian challenge (www.wwnorton.com). Noting that across the US,
numerous regions, companies, and universities are experimenting with new ways to
promote and structure innovation, launching bottom-up efforts to create collaborative
communities, he adds that these efforts are grounded in the country’s comparative
advantage — ‘an open and flexible culture and a web of institutions, attitudes, and relations
that move ideas from the lab to the marketplace.’
Contd...
296 LOVELY PROFESSIONAL UNIVERSITY