Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

this c program for sorting of names is showing compilation errors in the pic. plz hlp.?

Attachment image

4 Answers

Relevance
  • 3 years ago
    Favorite Answer

    The message is a linker message, not a compiler message. The "ld" in the message text is the name of the linker program.

    It looks like you have another source file in your project that defines main(). You need to remove that source file or (if it has functions you plan to use) delete or rename main() in the other source.

    For future reference, going to the build log tab and pasting a copy of that text is much easier to read than a screenshot of the "build messages". Nothing gets truncated that way.

    The build messages tab is nice for you, since clicking on a message takes you to the related source line, but you have to hover or stretch to see the full message text.

  • 3 years ago

    C doesn't care if you define "main()" or "int main()" or "int main(int argc, char **argv)", so that is immaterial. As husoski said, the issue is a linker error. You have another function called main somewhere. Remove it, and your program will link.

  • 3 years ago

    As <Robert J> said, you might wanna try "int main()", but looking at the error message, it says you have multiple definitions of main. "main" is a reserved name and it serves as the entry point of the program, so it's obvious you can't have more than 1 main function. If you have other files within the same project that contain a main function, you should know that the compiler puts together every file of your project, so there might be a name collision (even if those 2 files don't communicate with each other)

  • 3 years ago

    main() conventionally is typed as an int

    try

    int main()

    ...

    Some compilers only the full definition, which is

    int main(int argc, char* argv[])

Still have questions? Get your answers by asking now.