C++ Help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chickendude
    Away from Computer
    FFR Simfile Author
    • Sep 2003
    • 1901

    #46
    RE: Re: RE: Re: RE: Re: RE: Re: C++ Help

    I've never used int main or void main and it worked with my compiler

    eh whatever, I'll start using it now just to be safe.

    Comment

    • soccr743
      FFR Player
      • Dec 2003
      • 549

      #47
      RE: Re: RE: Re: RE: Re: RE: Re: C++ Help

      Chickendude, saying "main() { }" is like saying "void main() { }".

      -----Soccr743-----

      Comment

      • ad0gg
        FFR Player
        • Dec 2003
        • 989

        #48
        RE: Re: RE: Re: RE: Re: RE: Re: C++ Help

        It is a good habit to use "int main() {}" because you can control where you want your program to end (unless of course you have some legitimate reason why you wouldn't want to control where you stop the program).

        Comment

        • chickendude
          Away from Computer
          FFR Simfile Author
          • Sep 2003
          • 1901

          #49
          RE: Re: RE: Re: RE: Re: RE: Re: C++ Help

          wait, does a function automatically end when something is returned?

          Comment

          • ad0gg
            FFR Player
            • Dec 2003
            • 989

            #50
            Re: RE: Re: RE: Re: RE: Re: RE: Re: C++ Help

            Originally posted by chickendude
            wait, does a function automatically end when something is returned?
            Yes.

            Comment

            • Necamus
              FFR Player
              • Nov 2005
              • 853

              #51
              RE: Re: RE: Re: RE: Re: RE: Re: RE: Re: C++ Help

              I would have to say using int main() is a great habit to get into. And a lot of the nuances (I think that is a word) of the code have to do with the compiler. I use Microsoft Visual C++ .Net. Pretty good, but it doesn't seem to like string variables.


              This is a good forum to go to for all your coding help.
              www.freerice.com

              Comment

              • ad0gg
                FFR Player
                • Dec 2003
                • 989

                #52
                ad0gg is awesome!

                Originally posted by Necamus
                I use Microsoft Visual C++ .Net. Pretty good, but it doesn't seem to like string variables.
                Are you using the actual "string" variable type (with the header string.h) or are you using character arrays? I find that character arrays, while a little more difficult to use, give you greater control over what you want to do. However, if you don't really need to do much with the string, type "string" is easier. But I still almost always use character arrays anyways.

                Comment

                • soccr743
                  FFR Player
                  • Dec 2003
                  • 549

                  #53
                  RE: ad0gg is awesome!

                  I didnt like the string class provided, so I built my own. Its not that hard and it is worth it. While you are at it, you should also do a List<type> class for a better array thing, Dictionary<keytype, valuetype> for a lookup. (Those latter classes use templating which is a useful thing to know).

                  -----Soccr743-----

                  Comment

                  • Necamus
                    FFR Player
                    • Nov 2005
                    • 853

                    #54
                    Re: ad0gg is awesome!

                    Originally posted by ad0gg
                    Originally posted by Necamus
                    I use Microsoft Visual C++ .Net. Pretty good, but it doesn't seem to like string variables.
                    Are you using the actual "string" variable type (with the header string.h) or are you using character arrays? I find that character arrays, while a little more difficult to use, give you greater control over what you want to do. However, if you don't really need to do much with the string, type "string" is easier. But I still almost always use character arrays anyways.
                    I can't remember what I was using...I tried it a few months ago, it didn't work, and I haven't found a need to use strings since.
                    www.freerice.com

                    Comment

                    • zajac
                      aka uAnimals
                      FFR Music Producer
                      • Aug 2003
                      • 4050

                      #55
                      RE: C++ Help

                      You could probably do it easier, and much more graphically presentable if you do it in Flash... I could probably whip something up for you in about half an hour... But since I'm too lazy to read the posts... I'm sure someone did this for you already anyways...
                      Originally posted by Spec & Aperson
                      We Rate You: Cool Motherfucer. 9/10

                      Comment

                      • igotrhythm
                        Fractals!
                        • Sep 2004
                        • 6535

                        #56
                        RE: C++ Help

                        I think the logic behind the int main() function where everything else goes is that the main function is supposed to return 0 if the program runs according to plan. More robust programs would include nonzero return values for the main program depending on where a certain kind of problem cropped up.

                        Getting back to the original question on page 1 (even though I know it's kind of a moot point), you could just enter the price of the item, declare the markup and tax variables as functions of the price of the item, then output the item's price, the markup, and the tax, then the final total by summing them. If my logic holds, you could even enter negative values for the markup to indicate that the item is discounted. And if the logic doesn't hold, at least it's a good test case.

                        Edit: I'm pretty good with algorithms, but I suck at coding. <_<
                        Originally posted by thesunfan
                        I literally spent 10 minutes in the library looking for the TWG forum on Smogon and couldn't find it what the fuck is this witchcraft IGR

                        Comment

                        • SpoOkyMagician
                          Forum User
                          • May 2004
                          • 378

                          #57
                          RE: Re: RE: Re: RE: Re: RE: Re: C++ Help

                          Junior year of high school. In my C++ class, we would go to addictinggames and follow links when we were done with our programming project.

                          I clicked a link called "Flash Flash Revolution" once, on a whim...

                          ...and here I am.
                          Whoa... You have a course on C++ in high school? What kind of school do you go to? In high school here, we wouldn't learn something like C++... in college we would; but High School? But however... On my senior project, i am trying game design with C++; and so far... I think i'm gonna fail... I understand some of it already since I make games with another program i use. Although, its not C++. it just has some things in it such as if, or, else, and whatnot... (Which i do understand...) it's just all the keywords in the language and stuff that i don't understand...

                          BTW by the time i read your responce, I should do my project. I don't have internet at home right now and I can't use the school's internet too often unless its for school work. right now, i have freetime... (which is rare here...) So if you do respond... I won't be able to read it for awhile... which really sucks... (I guess i'll come by later... bye.)

                          Comment

                          • Evilcatt09
                            FFR Player
                            • Feb 2006
                            • 3

                            #58
                            RE: Re: RE: Re: RE: Re: RE: Re: C++ Help

                            my high school has a C++ course and an AP Comp Science(Java) course and next year they are adding an honors java course to replace the C++ course, but my school is a magnet school for math,science,and technology so I guess thats why we have all that

                            Comment

                            Working...