Thread: Need help. Can't identify error.

  1. #16
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    All the same... we know that int main (void) works correctly everywhere but there is no guarantee that empty parenthese will.

    That said, the debate is interresting.

  2. #17
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by CommonTater View Post
    All the same... we know that int main (void) works correctly everywhere but there is no guarantee that empty parenthese will.
    ...
    Now I am one to use 'int main(void)' as well, however the purpose of the standard is to ensure that it will work everywhere. If you wind up running into a compiler that won't accept 'int main()' then you have met a non-compliant compiler and should probably get a new one.

    ....or I guess you could always get a job in India.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  3. #18
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by AndrewHunter View Post
    Now I am one to use 'int main(void)' as well, however the purpose of the standard is to ensure that it will work everywhere. If you wind up running into a compiler that won't accept 'int main()' then you have met a non-compliant compiler and should probably get a new one.

    ....or I guess you could always get a job in India.
    LOL...

    There are still a few up to date compilers that are not C-99 compliant... many are still working from C-89 or, in microsoft's case, from a set of self-made rules that serve their purposes.

  4. #19
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by CommonTater View Post
    LOL...
    There are still a few up to date compilers that are not C-99 compliant... many are still working from C-89 or, in microsoft's case, from a set of self-made rules that serve their purposes.
    Haha....that's because Microsoft and Walmart are secretly working together to take over the world!.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  5. #20
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by CommonTater
    There are still a few up to date compilers that are not C-99 compliant... many are still working from C-89 or, in microsoft's case, from a set of self-made rules that serve their purposes.
    As I noted in post #15, this feature where empty parentheses in function definition => no parameters is from C89. AndrewHunter just happened to quote from C99, which I deduced by the clause number. In fact, C99 marks the identifier list feature as obsolescent, though the draft of the next version of C that I have at hand retains it. Consequently...

    Quote Originally Posted by CommonTater
    we know that int main (void) works correctly everywhere but there is no guarantee that empty parenthese will.
    We don't know that int main(void) works correctly everywhere (and in fact we know that it doesn't: freestanding implementations), and if it does, then int main() will.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #21
    Registered User
    Join Date
    Jul 2011
    Posts
    25
    OKAY GUYS.... I'm a bit confused. Which should I use now?

  7. #22
    Registered User
    Join Date
    Jul 2011
    Posts
    25
    Quote Originally Posted by bummielove View Post
    OKAY GUYS.... I'm a bit confused. Which should I use now?
    Should I use int void ?

  8. #23
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Just use:
    Code:
    int main(void)
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  9. #24
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Seldom have I ever seen such a truly simple point so totally bemuddled, only to arrive right back at the original suggestion...

    Yes, use int main (void)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. identify my algorithm, please!
    By MK27 in forum Tech Board
    Replies: 8
    Last Post: 11-25-2009, 07:01 AM
  2. How to identify arrow-chars?
    By Zarniwoop in forum C Programming
    Replies: 5
    Last Post: 05-31-2009, 01:07 PM
  3. can you identify this car?
    By axon in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 07-19-2004, 02:59 PM

Tags for this Thread