help im an idiot

This is a discussion on help im an idiot within the C++ Programming forums, part of the General Programming Boards category; >Lack of a standard to conform to? Pfft. That's not a valid excuse. No-one set any standards for me, and ...

  1. #31
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    >Lack of a standard to conform to?
    Pfft. That's not a valid excuse. No-one set any standards for me, and look at me now!
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  2. #32
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >and look at me now!
    You don't really want me to comment on that, do you?
    My best code is written with the delete key.

  3. #33
    Registered User
    Join Date
    Mar 2004
    Posts
    220
    >...she says after writing a rather long explanation of stuff dealing with binary trees. Are you saying that it's OK to get it in ~4 years?

    I don't think that was the point she was trying to get across.

    >Pfft. That's not a valid excuse. No-one set any standards for me, and look at me now!

    Without standards, your code doesn't conform to everyone elses. Thus, your code cannot be easily joined by the numerous other programs developed from the standard. Hint:Your doing more work then you need to. There is a reason for standards, it keeps things clean and easy.
    OS: Windows XP Pro CE
    IDE: VS .NET 2002
    Preferred Language: C++.

  4. #34
    Registered User
    Join Date
    Nov 2003
    Posts
    26
    Originally posted by Death_Wraith
    #5
    Code:
    int main(int argc, char* argv[] )
    this isn't needed, BUT, its good coding style.

    What exactly is that and why is it good style? I always just delete it when the compiler adds it in heh.
    Regards,
    ~Joshua Norton

  5. #35
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >What exactly is that
    Arguments to main that allow you to take command line input from the program invocation.

    >why is it good style?
    If you don't use command line arguments then adding unnecessary clutter is bad style. You're also more likely to not get a clean compile if the compiler warns about unused variables.
    My best code is written with the delete key.

  6. #36
    Registered User
    Join Date
    Mar 2004
    Posts
    220
    If you don't understand what Prelude just said, this is a bit of a more detailed explenation.

    Basically, main() is a function, and it can take various parameters like any other function. The parameters it can take are known as 'argc' of an int type, and '*argv[]', which is an array of char type(notice asteriks), this can take array elements of strings. 'argc' of an int type, is equal to the number of elements in '*argv[]'.

    The first element in '*argv[]' is the filename of the source if I remember right. Then any other corresponding element in the array is whatever argument you pass to main() from the program invokator.

    The program invokator, is the operating system alot of the time. So lets say you go into 'run' on a windows machine, and type in 'programname /?'.

    '/?' is the argument that is passed into main() as *argv[1]. You can deal with arguments like any other function really. As an example:
    Code:
    int main(int argc, int *argv[])
    {
      for (int x = 0; x < argc; x++)
      {
        if (argv[i] == "/?")
             //Handle argument here.
      return 0;
      }
    Note that the program invokator is not limited to the operating system, and that 'argc' and '*argv[]' can be renamed to whatever you prefer.
    OS: Windows XP Pro CE
    IDE: VS .NET 2002
    Preferred Language: C++.

  7. #37
    Registered User
    Join Date
    Feb 2004
    Posts
    127
    Originally posted by Prelude

    That sounds like what we've been doing all along. You just have to wade through the dozen side conversations (that are all very interesting...sometimes) to find it.

    Yeah I know that but I found Death_Wraith explaining line by line the code.. so i said that

  8. #38
    Registered User
    Join Date
    Mar 2004
    Posts
    180
    Well I touched upon most of the arguments stated in this post.

    #1 the include line
    #2 the using namespace std;
    #3 return 0;
    #4 argc, int *argv[]
    #5 etc...

    <<Yeah I know that but I found Death_Wraith explaining line by line the code.. so i said that

    I just pretty much summed up the whole post. Trying to make life easier!

  9. #39
    vex
    vex is offline
    Registered User
    Join Date
    Mar 2004
    Posts
    6

    ok

    ok i got the program working by copy and pasting sircrono6 code. but sircrono6 you asked me " am i coping the code properly" i assure you i have and the only reason your code worked is that you added 2 more lines to the bottom of the code. why does this fix the problem and why isnt it in tutorial then? how am i suppose to learn when its not even a full code. thanks for all your help but i think im gonna shoot myself in the foot. its probably a lot less painfull

    Code:
    cin.get();cin.get();

  10. #40
    Registered User
    Join Date
    Mar 2004
    Posts
    180
    http://www.functionx.com/

    Best tutorial ever.

    BTW, what compiler are u using?

  11. #41
    Registered User
    Join Date
    Sep 2003
    Posts
    135

    Re: ok

    Originally posted by vex
    ok i got the program working by copy and pasting sircrono6 code. but sircrono6 you asked me " am i coping the code properly" i assure you i have and the only reason your code worked is that you added 2 more lines to the bottom of the code. why does this fix the problem and why isnt it in tutorial then? how am i suppose to learn when its not even a full code. thanks for all your help but i think im gonna shoot myself in the foot. its probably a lot less painfull

    Code:
    cin.get();cin.get();
    Adding cin.get() to the end of main doesn't fix anything except for the fact that some development environments (e.g. MS VC++) keep the console window open after the program has terminated when run from the IDE and some (e.g. Dev-C++) don't. By adding cin.get() you pause the program until the user presses enter.

    Adding cin.get() twice in a row is what people do when they don't realise why it doesn't work sometimes if you only add it once
    Gambling. The new yoga, with cash prizes!

  12. #42
    vex
    vex is offline
    Registered User
    Join Date
    Mar 2004
    Posts
    6
    im using devc++ 4.9.8.0. thanks for the link to function X death wraith. im about to try it out now. hope its better than stupid one on this website.

    p.s love the function x moto learn by practicing and practice by doing. ill get back to you on how i go. thanks for the help.

  13. #43
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696
    Originally posted by vex
    thanks for the link to function X death wraith. im about to try it out now. hope its better than stupid one on this website.
    heck, nothing will replace a good C++ book
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

  14. #44
    vex
    vex is offline
    Registered User
    Join Date
    Mar 2004
    Posts
    6
    i know but im a cheap bastard. i have changed to c instead c++ and i aint having any problems. go figure aye. maybe if this goes alright ill buy a book

    thanks all

    p.s for all you tech heads out th there please keep your answers simple for the new kids. half the posts i didnt understand cause i wasnt that advanced yet. keep up the great forum guys.

    bye for now

  15. #45
    Registered User
    Join Date
    Mar 2004
    Posts
    220
    Originally posted by vex
    i know but im a cheap bastard. i have changed to c instead c++ and i aint having any problems. go figure aye. maybe if this goes alright ill buy a book

    thanks all

    p.s for all you tech heads out th there please keep your answers simple for the new kids. half the posts i didnt understand cause i wasnt that advanced yet. keep up the great forum guys.

    bye for now
    Sorry about that Vex, but good luck with C, I hope you do well in it If ya ever come back to here, I hope ya understand it better, been a good time, so cya later.
    OS: Windows XP Pro CE
    IDE: VS .NET 2002
    Preferred Language: C++.

Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Idiot spammer.
    By brewbuck in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 03-23-2009, 09:19 PM
  2. Feel Like An Idiot
    By golfinguy4 in forum A Brief History of Cprogramming.com
    Replies: 22
    Last Post: 07-04-2003, 01:45 PM
  3. Screaming idiot - shuttle "photo".
    By adrianxw in forum A Brief History of Cprogramming.com
    Replies: 19
    Last Post: 03-08-2003, 08:44 PM
  4. Replies: 0
    Last Post: 02-24-2002, 09:03 PM
  5. Idiot Canadians
    By Troll_King in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 10-15-2001, 08:35 AM

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