i have three simple questions...

This is a discussion on i have three simple questions... within the C Programming forums, part of the General Programming Boards category; 1. Why do I use "void main()"? 2.Why do I use "main(void)"? .3 Why do I use "return 0" sometimes ...

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    11

    i have three simple questions...

    1. Why do I use "void main()"?


    2.Why do I use "main(void)"?


    .3 Why do I use "return 0" sometimes and not void main()?


    Im having a tough time understanding these simple things but my teacher tells me just to follow what he does to avoid the delays with "details" like those.

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,159
    It's right in the FAQ on this site: http://faq.cprogramming.com/cgi-bin/...&id=1043284376
    If you understand what you're doing, you're not learning anything.

  3. #3
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    Im having a tough time understanding these simple things but my teacher tells me just to follow what he does to avoid the delays with "details" like those.
    It seems unfair now (in fact, the fact that he told you he wasn't telling you why because you were causing delays and worrying about details is a really crappy excuse if you ask me), but there's a good reason why most tutorials won't explain this sort of stuff right away. You'll understand the answer to all of your questions as you continue learning the different aspects of C. These different aspects are necessary for even the simplest of programs, but the concepts are too advanced to explain in the first couple of days. Patience, my friend... I know it sucks not to understand something, but you'll see why you had to wait later on.

  4. #4
    Registered User
    Join Date
    Jun 2004
    Posts
    84
    True, but what kind of teacher would teach stuff that have been obsolete for 15 years? My opinion, baaaaad teacher.
    Like one course I took last year. Guy came in and said "I don't really know how to programm, but I will try to teach you. Let's just copy and paste some code and see how it works" . Next time I walked in class room was during exams...

  5. #5
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    A question...

    In the faq there, is it saying NOT to use
    Code:
    int main ( void )
    in C++?

    Does the idea of function_name ( void ) when no arguments are used only aply to C and not C++?
    What is C++?

  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    It's fine to specify void as the parameter type. That specificly means that the function will not have any arguments. I suspect with C++ that it's purely stylistic, as there definately isn't anything prohibiting you declaring a function as void for its arguments. Since if you don't specify the arguments in C++ it means it has none, as opposed to its meaning in C, it's just been obsoleted, or rather, it's just extra typing.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. questions....so many questions about random numbers....
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 07-30-2009, 08:47 AM
  2. A couple questions
    By Flakster in forum C++ Programming
    Replies: 7
    Last Post: 08-09-2005, 01:22 PM
  3. Few simple questions...
    By Shane in forum C++ Programming
    Replies: 9
    Last Post: 08-06-2005, 02:40 AM
  4. A few simple batch questions
    By sean in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 07-02-2003, 01:35 PM
  5. questions questions questions.....
    By mfc2themax in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 08-14-2001, 07:22 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21