Error executing link.exe??

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • surlogics@gmail.com

    Error executing link.exe??

    The function of the program is to output the longest word in a
    sentence.

    #include<stdio. H>
    #include<string .H>
    main()
    {int alphabetic(char );
    int longest(char []);
    int i;
    char line[100];
    printf("input one line");
    gets(line);
    printf("the longest word is:");
    for(i=longest(l ine);alphabetic (line[i]);i++)
    printf("%c",lin e[i]);
    }

    int alphabetic(char c)
    {if((c>='a'&&c< ='z')||(c>='A'& &c<='Z'))
    return(1);
    else
    return(0);
    }

    int longest(char string[])
    {int alphabetic(char c);
    int i,length=0,len= 0,place,inaword =0; /*inaword=0 refers to the
    "cursor" is not in a word*/
    for(i=0;i<=strl en(string);i++)
    {if(alpabetic(s tring[i]))
    {inaword=1;
    place=i;
    len++;}
    else
    {inaword=0;
    if(length<len)
    {length=len;
    place=i;
    len=0;
    }
    }
    }
    return(place);
    }


    But when i try to link(visual c++6), it said
    "Linking...
    c.obj : error LNK2001: unresolved external symbol _alpabetic
    Debug/c.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe."

    I don't understand why.Can anyone help me? Thx!
  • Martin Ambuhl

    #2
    Re: Error executing link.exe??

    surlogics@gmail .com wrote:

    Here's the declaration:
    {int alphabetic(char );
    And the error message:
    "Linking...
    c.obj : error LNK2001: unresolved external symbol _alpabetic
    I don't understand why.Can anyone help me? Thx!
    I'm not "Thx", but even I can notice that "alpabetic" and "alphabetic "
    are not the same.

    Comment

    • Martin Ambuhl

      #3
      Re: Error executing link.exe??

      raashid bhatt wrote:
      what are u doing man function prototype inside another function?
      int alphabetic(char );
      int longest(char []);
      There is nothing wrong with having a declaration inside another
      function. If that fellow with the short name "u" can do it.
      take them outside main
      There is no need.
      >
      and append __cdecl before fucntion name
      There is nothing in the C programming language named "__cdecl" and, even
      if there were, it has nothing to do with his problem, which was simply
      misspelling his identifier.

      Comment

      • Ian Collins

        #4
        Re: Error executing link.exe??

        surlogics@gmail .com wrote:
        The function of the program is to output the longest word in a
        sentence.
        >
        #include<stdio. H>
        #include<string .H>
        These shouldn't have a capital H.
        main()
        That should be int main(void)
        {int alphabetic(char );
        int longest(char []);
        int i;
        char line[100];
        printf("input one line");
        gets(line);
        Never, ever use gets. Use fgets(line, 100, stdin) and change 100 to a
        named constant.
        printf("the longest word is:");
        for(i=longest(l ine);alphabetic (line[i]);i++)
        printf("%c",lin e[i]);
        }
        >
        int alphabetic(char c)
        {if((c>='a'&&c< ='z')||(c>='A'& &c<='Z'))
        return(1);
        else
        return(0);
        }
        >
        int longest(char string[])
        {int alphabetic(char c);
        int i,length=0,len= 0,place,inaword =0; /*inaword=0 refers to the
        "cursor" is not in a word*/
        for(i=0;i<=strl en(string);i++)
        {if(alpabetic(s tring[i]))
        You spelt alphabetic wrong here.
        --
        Ian Collins.

        Comment

        • Ian Collins

          #5
          Re: Error executing link.exe??

          raashid bhatt wrote:
          >
          what are u doing man function prototype inside another function?
          int alphabetic(char );
          int longest(char []);
          >
          There's nothing wrong with putting function prototypes in a function body.
          take them outside main
          >
          and append __cdecl before fucntion name
          Why on Earth would anyone do that?

          --
          Ian Collins.

          Comment

          • raashid bhatt

            #6
            Re: Error executing link.exe??

            On Aug 16, 7:16 pm, surlog...@gmail .com wrote:
            The function of the program is to output the longest word in a
            sentence.
            >
            #include<stdio. H>
            #include<string .H>
            main()
            {int alphabetic(char );
             int longest(char []);
             int i;
             char line[100];
             printf("input one line");
             gets(line);
             printf("the longest word is:");
             for(i=longest(l ine);alphabetic (line[i]);i++)
                     printf("%c",lin e[i]);
            >
            }
            >
            what are u doing man function prototype inside another function?
            int alphabetic(char );
            int longest(char []);

            take them outside main

            and append __cdecl before fucntion name
            Thanks!!

            Comment

            • Andrew Poelstra

              #7
              Re: Error executing link.exe??

              On 2008-08-17, surlogics@gmail .com <surlogics@gmai l.comwrote:
              The function of the program is to output the longest word in a
              sentence.
              >
              Well, you've got a number of problems (I won't mention stylistic
              concerns, but suffice to say this code is very hard to read):
              #include<stdio. H>
              #include<string .H>
              These should be .h, not .H.
              main()
              int main(void)
              {int alphabetic(char );
              int longest(char []);
              int i;
              char line[100];
              printf("input one line");
              gets(line);
              *Never* use gets(). It is bug unto itself. Instead try
              fgets(line, sizeof line, stdin);
              printf("the longest word is:");
              for(i=longest(l ine);alphabetic (line[i]);i++)
              There is a standard C function (macro?) isalpha() you could use instead
              of alphabetic().
              printf("%c",lin e[i]);
              Another standard C function, putc(), will do this for you.
              }
              >
              int alphabetic(char c)
              {if((c>='a'&&c< ='z')||(c>='A'& &c<='Z'))
              return(1);
              else
              return(0);
              }
              There's no guarantee that this will work: what if you are using a
              character set where letters are not consecutive? Use isalpha() instead.
              >
              int longest(char string[])
              {int alphabetic(char c);
              Consider giving function prototypes file scope, and moving them to
              shared header files. This makes them easier to update.
              int i,length=0,len= 0,place,inaword =0; /*inaword=0 refers to the
              "cursor" is not in a word*/
              for(i=0;i<=strl en(string);i++)
              {if(alpabetic(s tring[i]))
              Here is your reported error. You spelt alphabetic() wrong.
              {inaword=1;
              place=i;
              len++;}
              else
              {inaword=0;
              if(length<len)
              {length=len;
              place=i;
              len=0;
              }
              }
              }
              return(place);
              }
              >
              Yikes! Consider using pointers instead to make this function
              more concise. You could do it with three local variables, as
              opposed to the 6 you are using now.

              --
              Andrew Poelstra apoelstra@wpsof tware.com
              To email me, use the above email addresss with .com set to .net

              Comment

              • Barry Schwarz

                #8
                Re: Error executing link.exe??

                On Sat, 16 Aug 2008 19:16:19 -0700 (PDT), surlogics@gmail .com wrote:
                >The function of the program is to output the longest word in a
                >sentence.
                >
                >#include<stdio .H>
                C is case sensitive. The correct header is stdio.h.
                >#include<strin g.H>
                >main()
                >{int alphabetic(char );
                int longest(char []);
                int i;
                char line[100];
                printf("input one line");
                gets(line);
                printf("the longest word is:");
                for(i=longest(l ine);alphabetic (line[i]);i++)
                Horizontal white space is not completely cost free but it is a very
                cheap way to improve the readability of your code. At a minimum, add
                a space after each semicolon.
                > printf("%c",lin e[i]);
                >}
                >
                >int alphabetic(char c)
                This entire function is unnecessary as there is already a standard C
                function to do this.
                >{if((c>='a'&&c <='z')||(c>='A' &&c<='Z'))
                This test is valid in ASCII. However, it yields incorrect results in
                EBCDIC.
                > return(1);
                return is a statement, not a function. The parentheses are allowed
                but unnecessary.
                else
                > return(0);
                >}
                >
                >int longest(char string[])
                The name string is reserved for the implementation. It would benefit
                you not to use names starting with "str".
                >{int alphabetic(char c);
                If you would place your prototypes at file scope at the beginning of
                your source, you would not have to repeat them.
                >int i,length=0,len= 0,place,inaword =0; /*inaword=0 refers to the
                >"cursor" is not in a word*/
                for(i=0;i<=strl en(string);i++)
                {if(alpabetic(s tring[i]))
                Maybe your keyboard has a problem with the character "h". Here it is
                missing.
                > {inaword=1;
                > place=i;
                You only want to do this if this is the very first character in the
                word. Otherwise place will end up as the index of the last character
                in the word.
                > len++;}
                else
                > {inaword=0;
                > if(length<len)
                > {length=len;
                > place=i;
                I'm pretty sure you don't want this line here at all. This will cause
                place to be the index of the character one byte beyond the end of the
                word.
                > len=0;
                > }
                > }
                }
                return(place);
                >}
                >
                >
                >But when i try to link(visual c++6), it said
                >"Linking...
                >c.obj : error LNK2001: unresolved external symbol _alpabetic
                >Debug/c.exe : fatal error LNK1120: 1 unresolved externals
                >Error executing link.exe."
                >
                >I don't understand why.Can anyone help me? Thx!
                --
                Remove del for email

                Comment

                • Joachim Schmitz

                  #9
                  Re: Error executing link.exe??

                  Barry Schwarz wrote:
                  On Sat, 16 Aug 2008 19:16:19 -0700 (PDT), surlogics@gmail .com wrote:
                  >
                  >The function of the program is to output the longest word in a
                  >sentence.
                  >>
                  >#include<stdio .H>
                  >
                  C is case sensitive. The correct header is stdio.h.
                  The filesystem might notbe case sensitive...
                  one platform I konw of doesn't use the '.' to separate filename from
                  extension so #include <stdiohdoes work too, as does #include <StdIoH>, as
                  that system isn't case sensiteve either.

                  no reason though to not use the correct stdio.h of course.


                  Bye, Jojo


                  Comment

                  • Andrew Poelstra

                    #10
                    Re: Error executing link.exe??

                    On 2008-08-17, Joachim Schmitz <nospam.jojo@sc hmitz-digital.dewrote :
                    Barry Schwarz wrote:
                    >On Sat, 16 Aug 2008 19:16:19 -0700 (PDT), surlogics@gmail .com wrote:
                    >>
                    >>The function of the program is to output the longest word in a
                    >>sentence.
                    >>>
                    >>#include<stdi o.H>
                    >>
                    >C is case sensitive. The correct header is stdio.h.
                    >
                    The filesystem might notbe case sensitive...
                    >
                    That doesn't necessarily have anything to do with stdio.h. The C
                    Standard does not require headers to be actual files, though they
                    commonly are.

                    --
                    Andrew Poelstra apoelstra@wpsof tware.com
                    To email me, use the above email addresss with .com set to .net

                    Comment

                    • Keith Thompson

                      #11
                      Re: Error executing link.exe??

                      Barry Schwarz <schwarzb@dqel. comwrites:
                      On Sat, 16 Aug 2008 19:16:19 -0700 (PDT), surlogics@gmail .com wrote:
                      >>The function of the program is to output the longest word in a
                      >>sentence.
                      >>
                      >>#include<stdi o.H>
                      >
                      C is case sensitive. The correct header is stdio.h.
                      [...]

                      Essentially correct, but ...

                      The interpretation of header names, including whether they're
                      case-sensitive or not, is implementation-defined.

                      "#include <stdio.h>" is certainly the correct form, and
                      "#include <stdio.H>" should be avoided. My point is that the latter
                      won't necessarily be flagged as an error (it's likely to be accepted
                      on Windows, for example).

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

                      • Andrew Poelstra

                        #12
                        Re: Error executing link.exe??

                        On 2008-08-17, Barry Schwarz <schwarzb@dqel. comwrote:
                        On Sat, 16 Aug 2008 19:16:19 -0700 (PDT), surlogics@gmail .com wrote:
                        >>
                        >>int longest(char string[])
                        >
                        The name string is reserved for the implementation. It would benefit
                        you not to use names starting with "str".
                        >
                        In this case, he could use String with a capital S. (Note that for
                        external variables this is not generally true since linkers are not
                        required to be case-sensitive).

                        --
                        Andrew Poelstra apoelstra@wpsof tware.com
                        To email me, use the above email addresss with .com set to .net

                        Comment

                        • pete

                          #13
                          Re: Error executing link.exe??

                          Andrew Poelstra wrote:
                          On 2008-08-17, Barry Schwarz <schwarzb@dqel. comwrote:
                          >On Sat, 16 Aug 2008 19:16:19 -0700 (PDT), surlogics@gmail .com wrote:
                          >>int longest(char string[])
                          >The name string is reserved for the implementation. It would benefit
                          >you not to use names starting with "str".
                          >>
                          >
                          In this case, he could use String with a capital S. (Note that for
                          external variables this is not generally true since linkers are not
                          required to be case-sensitive).
                          Function names beginning with str followed by a lower case letter,
                          are reserved for the implementation.

                          I don't see anything wrong with:
                          int longest(char string[])

                          --
                          pete

                          Comment

                          • Jack Klein

                            #14
                            Re: Error executing link.exe??

                            On Sun, 17 Aug 2008 10:54:32 -0700, Barry Schwarz <schwarzb@dqel. com>
                            wrote in comp.lang.c:
                            On Sat, 16 Aug 2008 19:16:19 -0700 (PDT), surlogics@gmail .com wrote:
                            [snip]
                            int longest(char string[])
                            >
                            The name string is reserved for the implementation. It would benefit
                            you not to use names starting with "str".
                            That's overstating the case in general. In particular, the use of the
                            identifier "string" for the name of a function parameter is completely
                            valid and conforming.

                            To quote the standard, in paragraph 1 of 7.1.3, "Reserved
                            identifiers":

                            "All identifiers with external linkage in any of the following
                            subclauses (including the future library directions) are always
                            reserved for use as identifiers with external linkage."


                            ....and 7.26.11, in the "Future library directions" section:

                            "Function names that begin with str, mem, or wcs and a lowercase
                            letter may be added to the declarations in the <string.hheader ."

                            Since parameter names in function definitions have no linkage,
                            "string", or any other identifier beginning with "str" followed by a
                            lower case letter, is not reserved in this situation. Nor would it be
                            reserved at file scope, as long as it was restricted to internal
                            linkage with the static keyword.

                            --
                            Jack Klein
                            Home: http://JK-Technology.Com
                            FAQs for
                            comp.lang.c http://c-faq.com/
                            comp.lang.c++ http://www.parashift.com/c++-faq-lite/
                            alt.comp.lang.l earn.c-c++

                            Comment

                            Working...