yay I made it all by myself

This is a discussion on yay I made it all by myself within the C++ Programming forums, part of the General Programming Boards category; It worked because on your machine, with your compiler, today, the iostream header also included other headers that were enough ...

  1. #16
    Registered User
    Join Date
    Jan 2005
    Posts
    7,328
    It worked because on your machine, with your compiler, today, the iostream header also included other headers that were enough to expose the srand, rand, and time functions.

    BTW, nice job on making the working program on your own. That is a feat.

  2. #17
    Registered User
    Join Date
    Jan 2005
    Posts
    46
    Quote Originally Posted by Kybo_Ren
    No, main() does not have to return anything. It must specify int as its return type, but it doesn't have to return anything.
    there's a difference between what you can get away with and what's good programming style

  3. #18
    Registered User Sake's Avatar
    Join Date
    Jan 2005
    Posts
    89
    Quote Originally Posted by Strait
    there's a difference between what you can get away with and what's good programming style
    In this case it's neither good nor bad because C++ guarantees that not returning a value is equivalent to returning 0. Some people prefer not to return anything, while some prefer to always return a value. Both are right.
    Kampai!

  4. #19
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    In this case it's neither good nor bad because C++ guarantees that not returning a value is equivalent to returning 0. Some people prefer not to return anything, while some prefer to always return a value. Both are right.
    Yes, in C++ if no return value is specified for main a return value of 0 is implied by the compiler. However just as with the arguments for casting malloc, this is considered bad programming practice and should be avoided. You should always explicitly return a value from main.
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

  5. #20
    Registered User
    Join Date
    Jan 2005
    Posts
    7,328
    Quote Originally Posted by andyhunter
    Yes, in C++ if no return value is specified for main a return value of 0 is implied by the compiler. However just as with the arguments for casting malloc, this is considered bad programming practice and should be avoided. You should always explicitly return a value from main.
    If you are not using the return value, then it is perfectly acceptable, IMO, to let the implicit return 0 do its job. It is not considered bad programming practice. You might consider it to be poor style, I think it is better style than adding an unnecessary return 0 to the end of your program. Either way it is a style issue, and has no effect on the actual program under a standards conforming compiler.

  6. #21
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Well, I wouldn't call it poor programming style, as it is rather nicely defined what it does (returns 0 which is the standard for a successful exit). Instead of saying that you don't have to return a value, though (as it clearly does return a value), I'd word it as, "you don't have to explicitly return a value."

    Cheers
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  7. #22
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    University of Waterloo
    Posts
    1,903
    http://www.research.att.com/~bs/bs_faq2.html#void-main

    Quote Originally Posted by Bjarne Stroustrup
    In C++, main() need not contain an explicit return statement. In that case, the value returned is 0, meaning successful execution. For example:

    Code:
        #include<iostream>
    
        int main()
        {
            std::cout << "This program returns the integer value 0\n";
        }

  8. #23
    Registered User
    Join Date
    Dec 2004
    Posts
    465
    Sooooooo...... anyone have a suggestion for a program that I could make?
    My computer is awesome.

  9. #24
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    You know it is a real shame that people do not take the time to truly see what this board has to offer. A lot of thought evidently went into the design and yet everyone always skips over everything and goes straight for the discussion boards. Yes, we all like attention - but please.

    Why don't you have a look here . It is something very useful that will help you practice and improve your programming skills.
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

  10. #25
    Pokemon Master digdug4life's Avatar
    Join Date
    Jan 2005
    Location
    Mystic Island, NJ
    Posts
    91
    wow i still have no idea what im doing

  11. #26
    Registered User
    Join Date
    Jul 2004
    Posts
    53
    Try to make a basic calculator that will ask each number separately:

    Output: What operation do you need ?
    Input: +
    Output: a ?
    Input: 5
    Output: b ?
    Input: 6
    Output: 11

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Small 3D Art Gallery I made
    By BobMcGee123 in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 07-06-2005, 06:03 PM
  2. nifty little thing i made
    By DavidP in forum C++ Programming
    Replies: 1
    Last Post: 12-05-2003, 10:43 PM
  3. Decompiler for *.exe made in c/c++
    By shagauravh in forum C Programming
    Replies: 7
    Last Post: 09-22-2001, 07:48 PM
  4. home made movies and animations
    By iain in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 09-02-2001, 11:16 AM

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