Re: char* argv[]



William Pursell said:

On Dec 14, 11:30 pm, Richard Heathfield <r...@xxxxxxxxxxxxxxx> wrote:
Logan said:

int main(int argc, char *argv) {
<snip>

Your second program thinks argv is a string, which it isn't.

No.

Your "correction" is incorrect.

In the second program, argv is a pointer to
an array of characters.

No, in the second program argv is (incorrectly defined as) a pointer to the
*first element* in an array of characters. The program then uses this
value as an argument matching a printf %s format specifier - in other
words, the program thinks argv is a string (just as I claimed), and is
using it as one.

C doesn't have a string type.

Non sequitur. I didn't claim that C has a string type.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
.



Relevant Pages

  • Re: ps output length for command tail
    ... 80 characters of the exec string and puts it in a kernel buffer. ... string never changes during the life of the process, ... The problem is that access to the processes ARGV is tricky to arrange ... On at least a couple of the machines I checked, Solaris 9 installed ...
    (comp.unix.solaris)
  • Re: char* argv[]
    ... in the second program argv is a pointer to the ... *first element* in an array of characters. ... I didn't claim that C has a string type. ...
    (comp.lang.c)
  • Re: char* argv[]
    ... Your second program thinks argv is a string, ... in the second program argv is a pointer to the ... *first element* in an array of characters. ...
    (comp.lang.c)
  • Re: char* argv[]
    ... Your second program thinks argv is a string, ... an array of characters. ...
    (comp.lang.c)
  • Re: input to mex function
    ... either cell arrays with string elements or ... or you can call it like this (string arguments): ... void mexFunction(int nlhs, mxArray *plhs, int nrhs, ... // Your code goes here to use argc and argv. ...
    (comp.soft-sys.matlab)