V
vicky
hi all,
please tell me with example, how the *argv[] point to the the no of
strings.
please tell me with example, how the *argv[] point to the the no of
strings.
hi all,
please tell me with example, how the *argv[] point to the the no of
strings.
vicky said:hi all,
please tell me with example, how the *argv[] point to the the no of
strings.
In said:please tell me with example, how the *argv[] point to the the no of
strings.
please tell me with example, how the *argv[] point to the the no of
strings.
argv is an array of character strings.
Malcolm McLean said:If you are asking how the argv array is set up, main() isn't the real entry
point to the program. There is some startup-code which queries the
command-line interface for the input, and sets up strings for main() to
read. However it is very platform-specific and normally you never need to
know about it.
John Gordon wrote On 06/27/07 16:38,:In <[email protected]> vicky
please tell me with example, how the *argv[] point to the the no of
strings.
argv is an array of character strings.
Almost: argv is an array of pointers, and those
pointers point to the beginnings of character strings.
Eric Sosman said:John Gordon wrote On 06/27/07 16:38,:In said:please tell me with example, how the *argv[] point to the the no of
strings.
argv is an array of character strings.
Almost: argv is an array of pointers, and those
pointers point to the beginnings of character strings.
Richard said:Eric Sosman said:
John Gordon wrote On 06/27/07 16:38,:Almost: argv is an array of pointers, and thoseIn <[email protected]> vicky
please tell me with example, how the *argv[] point to the the no of
strings.
argv is an array of character strings.
pointers point to the beginnings of character strings.
Almost: argv is a pointer to the first element in an array of pointers.
hi all,
please tell me with example, how the *argv[] point to the the no of
strings.
Your question doesn't make much sense. You seem to be asking for an
example of how *argv[] points to the number of argv strings. Well, it
doesn't.
However, given a main() function prototype of
int main(int argc, char *argv[]);
then, upon initial entry into main(),
argc will have been set to the count of the number of strings that
argv will point to, and
argv will have been set to point to an array of pointers to the
individual strings
Thus,
argv[0] will point to the "program name" string, what ever that is,
argv[1] will point to the first argument string,
argv[2] will point to the second argument string,
and so on, with
argv[argc-1] pointing to the last argument string, and
argv[argc] pointing at a NULL pointer
Barry Schwarz said:Just a nit since your code handles it correctly. argv[argc] doesn't
point to a NULL pointer; it is a NULL pointer. Or, it you prefer, it
is a pointer that has been set to NULL.
Y'know, I thought to myself as I wrote it, "Self," I
thought, "some pedant is going to pedantize you for this.
How very pedantestrian."
As a function argument, an array is all but indistinguishable
from a pointer.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.