Segmentation fault error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Richard Heathfield

    #16
    Re: Segmentation fault error

    dj3vande@csclub .uwaterloo.ca.i nvalid said:
    In article <hqidnZAaNdgLDh TVnZ2dneKdnZydn Z2d@bt.com>,
    Richard Heathfield <rjh@see.sig.in validwrote:
    >>enjoyfate@gma il.com said:
    >
    >>void main (int argc, char *argv[])
    >
    >>int main(int argc, char **argv)
    >
    >
    >>Every difference between the above version and your version is
    >>significant .
    >
    *Every* difference? What's the significance of "char *argv[]" vs.
    "char **argv"?
    Documentary. The newer syntax fully recognises the "new" <coughpointer
    syntax. Using the [] syntax for pointer parameters is like saying
    "forsooth" and "oddsbodkin s" - legal, but nevertheless an archaic
    affectation.

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

    Comment

    • Richard Tobin

      #17
      Re: Segmentation fault error

      In article <Ke-dnS_j0rvtehHVnZ 2dnUVZ8umdnZ2d@ bt.com>,
      Richard Heathfield <rjh@see.sig.in validwrote:
      >*Every* difference? What's the significance of "char *argv[]" vs.
      >"char **argv"?
      >Documentary. The newer syntax fully recognises the "new" <coughpointer
      >syntax. Using the [] syntax for pointer parameters is like saying
      >"forsooth" and "oddsbodkin s" - legal, but nevertheless an archaic
      >affectation.
      On the contrary; the "old" syntax documents that the argument refers
      to an array, rather than merely being a pointer used to return a value.
      The "new" syntax conflates the two.

      -- Richard
      --
      Please remember to mention me / in tapes you leave behind.

      Comment

      • Richard Heathfield

        #18
        Re: Segmentation fault error

        Richard Tobin said:
        In article <Ke-dnS_j0rvtehHVnZ 2dnUVZ8umdnZ2d@ bt.com>,
        Richard Heathfield <rjh@see.sig.in validwrote:
        >
        >>*Every* difference? What's the significance of "char *argv[]" vs.
        >>"char **argv"?
        >
        >>Documentary . The newer syntax fully recognises the "new" <coughpointer
        >>syntax. Using the [] syntax for pointer parameters is like saying
        >>"forsooth" and "oddsbodkin s" - legal, but nevertheless an archaic
        >>affectation .
        >
        On the contrary; the "old" syntax documents that the argument refers
        to an array, rather than merely being a pointer used to return a value.
        The "new" syntax conflates the two.
        On the contrary... well, okay, let's call that a style issue and agree to
        differ.

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

        Comment

        • CBFalconer

          #19
          Re: Segmentation fault error

          dj3vande@csclub .uwaterloo.ca.i nvalid wrote:
          Richard Heathfield <rjh@see.sig.in validwrote:>
          >>void main (int argc, char *argv[])
          >
          >int main(int argc, char **argv)
          >
          >Every difference between the above version and your version is
          >< significant.
          >
          *Every* difference? What's the significance of "char *argv[]"
          vs. "char **argv"?
          In a function header describing a parameter, none. The parameter
          is always passed as a pointer to a pointer to char. The void type
          for main is a horror.

          --
          [mail]: Chuck F (cbfalconer at maineline dot net)
          [page]: <http://cbfalconer.home .att.net>
          Try the download section.


          Comment

          • Keith Thompson

            #20
            Re: Segmentation fault error

            richard@cogsci. ed.ac.uk (Richard Tobin) writes:
            In article <Ke-dnS_j0rvtehHVnZ 2dnUVZ8umdnZ2d@ bt.com>,
            Richard Heathfield <rjh@see.sig.in validwrote:
            >>*Every* difference? What's the significance of "char *argv[]" vs.
            >>"char **argv"?
            >
            >>Documentary . The newer syntax fully recognises the "new" <coughpointer
            >>syntax. Using the [] syntax for pointer parameters is like saying
            >>"forsooth" and "oddsbodkin s" - legal, but nevertheless an archaic
            >>affectation .
            >
            On the contrary; the "old" syntax documents that the argument refers
            to an array, rather than merely being a pointer used to return a value.
            The "new" syntax conflates the two.
            The *language* conflates the two. The "new" syntax accurately
            reflects this conflation. Using [] in a parameter declaration
            documents the intent, but doesn't enforce it. A comment is, IMHO, a
            better way to do this, and also gives you the opportunity to provide
            more information, such as that a char* parameter points to a string,
            not just to the first element of some arbitrary array.

            (As I recall, one of C's ancient ancestors, either B or BCPL, actually
            used "[]" as the syntax for pointers; thus the reference to the
            <cough"new" pointer syntax.)

            --
            Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
            Nokia
            "We must do something. This is something. Therefore, we must do this."
            -- Antony Jay and Jonathan Lynn, "Yes Minister"

            Comment

            • David Thompson

              #21
              Re: Segmentation fault error

              On Fri, 25 Jul 2008 15:19:25 +0530, santosh <santosh.k83@gm ail.com>
              wrote:
              lovecreatesbea. ..@gmail.com wrote:
              How then is main function invoked, if the relevant argv[0] is null?
              >
              The two have no relationship. How main is invoked is implementation
              defined. If argc is non-zero then argv[0] points to a string which
              contains the command by which the program was invoked. If no such
              string can be had from the environment then argv[0][0] is a null
              character. Whether or not argc is zero or non-zero argv[argc] is always
              a null pointer.
              >
              I'd make a distinction here: argv[0] is officially supposed to be, or
              rather 'represent', the program name. On many systems and in many
              cases, the command used to invoke a program is some form of its name,
              but not always; aside from aliases and symlinks and such, where it
              could be debated whether the source or the target is 'really' the
              command and/or the name, the most obvious example was Digital's DCL
              where on RT-11 for example COPY and DELETE both actually ran PIP.
              (Admittedly not a C program, and definitely not a portable one.)
              Note that the string pointed to by argv[0] may not necessarily be the
              actual name by which your program was invoked. Under many systems this
              string could be set to any name before invoking your program, so this
              not a 100% reliable means of obtaining the invocation command of your
              program.
              Yes, even though it's supposed to be the name, it might not.

              - formerly david.thompson1 || achar(64) || worldnet.att.ne t

              Comment

              Working...