New to C++

This is a discussion on New to C++ within the C++ Programming forums, part of the General Programming Boards category; OK, having compiled your program, you then need to run the program. The next button along (or the next menu ...

  1. #16
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,821
    OK, having compiled your program, you then need to run the program.
    The next button along (or the next menu option) should be something like "Run" or "Execute"
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  2. #17
    Registered User
    Join Date
    May 2007
    Posts
    10
    Yes, You are right, I did find that in the FAQ. I was going by the tutorial which instructed you to put in the line: cin.get() , to keep the window open

  3. #18
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Little bit of background of how stuff works under the hood:

    Your computer only understands a special language that is composed of 0's and 1's. This language is unique to each type of processor, and is typically referred to as machine language, or something similar. Since it's all just numbers, and humans don't do that well communicating with a computer in straight numbers, something called assembly language was created. It's basically a language for programmers where more or less each statement in assembly corresponds to one statement in machine language. So programmers would write their programs in assembly. Since computers obviously don't understand it, a program called an assembler is used to translate the assembly code to machine language.

    Assembly language is hard to get useful things done quickly, so that's why high level languages like C++ were created. Obviously, your computer doesn't understand C++ either. Therefore you have a C++ compiler, which is a program used to translate your C++ program ultimately to machine language (many languages are compiled first to assembly, and then assembled to machine language ).

    So anyway, with that said, you're supposed to write out a C++ program in a simple text file with a .cpp extension and save it. You then have the compiler translate the code in that file into machine language, and you will then have an exe file (or some equivalent executable, or something like a .dll). You can then run your program.

    And btw, this is a very simplified version of what really happens.

  4. #19
    Registered User
    Join Date
    May 2007
    Posts
    10
    "And btw, this is a very simplified version of what really happens."

    Thanks...for everything, everyone. When you showed me what I was doing wrong, I was going strictly by the tutorial, and you pointed out instead of cout<<"hello World" , you told me to use std::cout, .....so I tried it with the cin.get() command, which I hadn't done previously, and low and behold....

    Also, most of the commands in the FAQ gave me errors, so once I parsed it sown to just include iostream and the "std::cout<<"press enter to continue... it worked perfectly.

    So, now I can continue on with the tutorials...thanks again, and I promise to be more specific with my questions in the future....(cause I am sure I will have many)

  5. #20
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,479
    Just like to say if you choose DevC++ which is fine as a learning tool but get omthing more stable for larger programs. Do NOT turn code completion on. This is main cause of the bugs with the IDE, which you will find when you use classes or the indirection operator '->' with pointer notations.

    Good luck to you. C++ is a rewarding experience.
    I'm just trying to be a better person - My Name Is Earl

  6. #21
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,479
    The FAQ code is rather old to be honest. But it should be correct.
    I'm just trying to be a better person - My Name Is Earl

  7. #22
    0x01
    Join Date
    Sep 2001
    Posts
    88
    Quote Originally Posted by MacGyver View Post
    First thing to learn is how to communicate with other humans properly in context of programming.
    MacGyver, first thing you need to learn is how to communicate with other humans (not birds, bears, snakes or those extra terrestrials) who happen to be completely new to programming.
    Quote Originally Posted by MacGyver View Post
    You'll find that the reason you have trouble with programming later on is sometimes because you fail to think things through properly.
    Because we love to write flawed code on purpose...right?
    Quote Originally Posted by MacGyver View Post
    This is just what many newbie programmers go through because they have trouble thinking in "verbose terms", if I'm allowed to make that term up.
    You know, it could just be that... um, hes new? I guess it is a little odd when we usually understand all that there is to know at birth.

    Quote Originally Posted by MacGyver View Post
    When you tell us "nothing happened" when you tried to setup a compiler, that means nothing to us. If you are having car trouble, and you tell the mechanic that it "doesn't work", or that "nothing happens" when you try to start it, he has to look at it himself or ask you 20 questions until you tell him more about the problem for him to give a proper diagnosis. Try telling a doctor that your arm doesn't work. If it turns out that you mean you experience pain while moving it, you should say exactly that.
    Yeah JimRoach, ya stupid son of *itch! What the hell were you thinking? Do you want to get killed? This is the CBoard, you need to be a little bit more careful.

    Wow heh, that MacGyver is just oh so cool

    Quote Originally Posted by MacGyver View Post
    Lastly, enjoy C++, and programming in general, and welcome to cboard.
    Ahem. I just want to let you know... I too would like to welcome you to the cboard (but only because its ok with MacGyver) and enjoy C++, ok Buddy? Enjoy C++, it is MacGyvers creation afterall. ...............But I swear to G*d if you act up or deliberately disobey our precious smart-questions faq we'll #@#@^* #@*&$^ @#$^*&@# @#$&*^#@ your whole family! Oh, and did I say welcome to the cboard yet?
    Quote Originally Posted by MacGyver
    Yes, but your description of your problem was sorely lacking, to put it mildly.
    Whoa, JimRoach. We can all tell you, he did indeed put it mildly. He must be in a good mood or something because he usually doesn't do that.

    Quote Originally Posted by MacGyver
    So, did the code I give you work? If not, what did you try? What did you expect it to do? What actually happened?
    I think he expected it to tear a hole in the universe. He must have been very surprised when it just printed "Hello, World" to his screen.

    Quote Originally Posted by ChaosEngine
    in other words read this!!!

    It'd be great if there was some way of forcing people to read that doc before starting programming. Perhaps with eyelids held open and Beethoven played loudly....
    Yes, I agree. Instead of telling him what he needs to know, lets get him to read some lame faq written by some stoic obese individual so he can stop making our lives so difficult with his improper forum etiquette. However, its threads like this that give us the chance to increase our post counts and increase our cool-points by flaming the thread starter, throwing up a faq, and say things like "We should force people to read our smart-questions faq. Perhaps with eyelids held open and Beethoven played loudly...." Admit it ChaosEngine, you love these threads... c'mon, be honest.

    Incase you are thinking of complaining about this post, think again. It would be against the smart-questions faq under On Not Reacting Like A Loser:
    "Odds are you'll screw up a few times on hacker community forums — in ways detailed in this article, or similar. And you'll be told exactly how you screwed up, possibly with colourful asides. In public.
    When this happens, the worst thing you can do is whine about the experience, claim to have been verbally assaulted, demand apologies, scream, hold your breath, threaten lawsuits, complain to people's employers, leave the toilet seat up, etc. Instead, here's what you do: Get over it. It's normal. In fact, it's healthy and appropriate."

    So if any of you complain, I'll blow the whistle as loud as I can in your face and red card you. (and as the title of that section says, you will be reacting like a loser.. so becareful)
    Quote Originally Posted by swgh
    The FAQ code is rather old to be honest. But it should be correct.
    No more than 1 minute after your previous post. I have a better idea. After every word you type in a reply you can hit Submit Reply and stretch your post/reply through-out a thread simultaneously increasing your post count. This way, if your reply consists of 1000 words; you just increased your post count by 1000!

    JimRoach
    Tutorials (most of them) are not going to be enough for you. You need a book.

    1. Drive to your local book store (B&Nobles, Books-a-gazillion*2, etc)
    2. Find the computer section (you must to be IN the store to do this)
    3. Look for a modern book about C++ (do not get a reference book)
    4. Take the book off the shelf. Look in the book. (Place the weight of the book on your right hand, then use your left hand to peel back the cover to expose the pages)
    5. If the book looks like it will teach you C++ from the ground up, close the book. (take your left hand off the book and place it under the cover of the book and lift up)
    6. Walk over to a register (with the book in hand) and explain to the employee that you would like to purchase the book. (note: that you cannot walk out of the store until you pay for the book)

    Books will go into detail on why you are doing what you are doing, whats happening when you are doing whatever it is your doing and even tell you what NOT to do and things to watch out for. Some will even show you clever solutions to common problems.
    C++ Book Recommendations Read one, practice and when you encounter a problem or you can't grasp an idea; post it. (if you post code, be sure to place [ code ] ... [/ code ] tags around it)
    Last edited by knave; 05-12-2007 at 10:14 AM.

  8. #23
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Quote Originally Posted by knave View Post
    MacGyver, first thing you need to learn is how to communicate with other humans (not birds, bears, snakes or those extra terrestrials) who happen to be completely new to programming.
    I take it you're telling me that I come across as relatively non-friendly, which would be an accurate assessment. I hope no one takes offense at it, since this is the Internet, and text can be taken the wrong way at times.

    Quote Originally Posted by knave View Post
    Because we love to write flawed code on purpose...right?
    Mmm, no. Many times new programmers fail to think things through properly because they intuitively know how to do simple tasks, but they have very little experience with expressing how they are able to achieve the results. For example, many people are well able to tell you if a word is a palindrome, but that does not mean they can write a C/C++ function that will do the same thing. Many times they can't even break down the problem small enough to code it before they get themselves confused. Part of writing a function like this when brand new requires them to think differently than they might be used to.

    Quote Originally Posted by knave View Post
    You know, it could just be that... um, hes new?
    Yes, that's exactly what I said.

    Quote Originally Posted by knave View Post
    I think he expected it to tear a hole in the universe. He must have been very surprised when it just printed "Hello, World" to his screen.
    You want me to assume this guy is brand new, but that he's well familiar with a Hello, world program when he couldn't get one to work earlier? I'd rather not play 20 questions with people that tell me that the code I give them "doesn't work". I'd like to get through the garbage of lousy communications and cut to the heart of the matter. The person asking for help learns how to actually ask a question, as well as the solution to their question.

    Now as I said, I'm not the most friendliest person on the planet, but to my credit I do try to assist people. I find it irritating when people either cannot or choose not to express their thoughts in some complete form that I, or anyone else that could potentially help them, are able to understand.

    I naturally hope JimRoach was not offended by anything I said, since I really didn't mean anything to be offensive. From his reaction, I don't think he took my words the wrong way. In fact, I would imagine he would have more of a problem with your way of telling him how to hold and open a book, but I naturally could be wrong.

  9. #24
    0x01
    Join Date
    Sep 2001
    Posts
    88
    Quote Originally Posted by MacGyver View Post
    I take it you're telling me that I come across as relatively non-friendly, which would be an accurate assessment. I hope no one takes offense at it, since this is the Internet, and text can be taken the wrong way at times.
    You're right, text can be "taken the wrong way." However, in this case it wasn't. It was an "accurate assessment."

    Quote Originally Posted by MacGyver View Post
    Mmm, no. Many times new programmers fail to think things through properly because they intuitively know how to do simple tasks, but they have very little experience with expressing how they are able to achieve the results.
    He doesn't even understand a compiler. This is almost random...

    Is equivalent to:

    Many times new bicyclers fail to balance or use the pedals properly (when at first attempting to ride a bike) because they have become too accustomed to walking and running.

    And??? Does something like that even need to be said/posted? "some" of your posts remind me of cotton candy, when I try to eat it, it dissolves so quickly its like nothing was there.

    Quote Originally Posted by MacGyver View Post
    Yes, that's exactly what I said.
    Yeah... that was the problem. Did you think we needed a reminder? - Thanks?

    Quote Originally Posted by MacGyver
    So, did the code I give you work?
    It was standard C++.
    Quote Originally Posted by MacGyver
    What did you expect it to do?
    Print "Hello, World" maybe?
    Quote Originally Posted by MacGyver
    What actually happened?
    Yeah, it definitely printed "Hello, World"

    Quote Originally Posted by MacGyver View Post
    In fact, I would imagine he would have more of a problem with your way of telling him how to hold and open a book, but I naturally could be wrong.
    Naturally.
    Last edited by knave; 05-12-2007 at 02:41 PM.

  10. #25
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Quote Originally Posted by knave View Post
    You're right, text can be "taken the wrong way." However, in this case it wasn't. It was an "accurate assessment."
    Accurate assessment that I can be a non-friendly, but nevertheless, I think that quality applies to you more than me. My redeeming quality is that I attempt to help people with their difficulties, even if I'm rough about it. What's yours?

    Quote Originally Posted by knave View Post
    He doesn't even understand a compiler. This is almost random...
    That's why I did him the courtesy of attempting to explain a little bit of the concept of compiling code for a computer. I would venture to say that what I said to him assisted him. You, on the other hand, treated him as if he's retarded with your talk about opening and closing a book in extreme details. That's arrogance on your part to tell everyone off for supposedly treating him badly or acting selfishly to increase their post count, and then you turn around and act worse than anything the rest of us did in this topic.

    Apparently you have a severe attitude problem, and probably a desire to be in the spotlight, since there's no other reason to attack three people in this thread the way you did, and then make fun of a new programmer in that manner.

    Quote Originally Posted by knave View Post
    Is equivalent to:

    Many times new bicyclers fail to balance or use the pedals properly (when at first attempting to ride a bike) because they have become too accustomed to walking and running.
    Most of the time this problem is apparent to a beginner. They know before they get on a bike they will most likely fall off. For a new programmer, however, before they try to write a function that does something simple, they don't necessarily see that both the problem and solution are simple, but just require lots of attention to small details.

    Quote Originally Posted by knave View Post
    And??? Does something like that even need to be said/posted? "some" of your posts remind me of cotton candy, when I try to eat it, it dissolves so quickly its like nothing was there.
    Yes, I think it needed to be said. Since he didn't ask his question with enough details, I don't think he did it on purpose to be a jerk about it. I think he honestly didn't realize he was being vague, and he eventually acknowledged that he incorrectly went about asking his question.

    Perhaps I should be more like yourself? Take this post of yours for instance. When you made a mistake, you flamed the moderator who pointed it out. Again, all indicative of a severe attitude problem.

    Quote Originally Posted by knave View Post
    Yeah... that was the problem. Did you think we needed a reminder? - Thanks?
    Apparently you thought it was important enough to restate.

    Quote Originally Posted by knave View Post
    It was standard C++.
    That's no guarentee that someone can't screw it up. Save it as a .c file and some compiler somewhere might compile it as C code, no? Never underestimate the ability of humans to mess up even simple tasks.

    Quote Originally Posted by knave View Post
    Print "Hello, World" maybe?
    Maybe. All depending upon if he was able to compile it exactly the way I gave it to him, and if he actually knew what it was doing.

    If he returned back and said, "It didn't work", and yet he was expecting something different, then I would have liked to know what he was expecting. All in all, I was trying to get him to realize that he needs to express himself better in order to receive the specific help he needs. Many times, people seem under the impression that their problems are so common that we can just diagnose them with practically no information.

    Quote Originally Posted by knave View Post
    Yeah, it definitely printed "Hello, World"
    Since you weren't watching over his shoulder, you can't be sure it actually printed properly, unless he confirms it, and even then you can't really be sure.

    That's great that you can disect a "Hello, world" program, and tell everyone what it does, but that's not the problem. The task is to communicate with the individual in question and making them understand something that they previously didn't understand before.

    Quote Originally Posted by knave View Post
    Naturally.
    Somehow, I don't think so. Perhaps if you focused on the good of people's posts instead of trying to beat down your supposed righteous view of C++, you might actually enjoy your experience here, which you definitely don't seem to be doing.

    But if you wish to pick a fight with everyone here, that's your choice. Yes, I know that's an obvious statement, but perhaps it's time someone talk to you as if you're an idiot.
    Last edited by MacGyver; 05-12-2007 at 03:35 PM. Reason: Spelling and grammar....

  11. #26
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    fight fight fight!

    has anyone realised the thread starter hasnt logged in since they made this thread and havent seen a single response (and probably wont ever)?

  12. #27
    Registered User
    Join Date
    May 2006
    Posts
    903
    knave, give it up, you don't have enough posts to be arguing. [/sarcasm]

  13. #28
    Registered User
    Join Date
    Jan 2005
    Posts
    7,344
    But Knave's been registered for 5 1/2 years longer.

    Not that I'm actually reading the discussion.

  14. #29
    Registered User
    Join Date
    May 2006
    Posts
    903
    Yes but the posts count more than date. Everyone knows that, Daved *rolls eyes*.

  15. #30
    Registered User
    Join Date
    May 2007
    Posts
    10
    Sorry, didn't mean to start a fight....

    However, the responses on the thread were very helpful, and made me more than a little fearful of asking another question....that being said,

    I went on to another example(using Deitel's Cpp, How to Program) this one added two intergers, but kept having same problem, and I was thinking that the code

    [ std::cout << "Press [Enter] to exit...";
    std::cin.get(); ]

    wasn't working because I had to hit enter to get the sum.....so i searched, and found another answer,

    [ char x='Y';
    while(x=='Y')
    {
    //...
    cout<<"Continue? (Y/N)";
    cin>>x; ]

    Which gave me the output, and kept the command line on the screen for me to actually see.

    Long post, I know, but thanks again, a little fear of getting flamed helped me plow through to find the answers myself!!

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

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