Some newbie questions

This is a discussion on Some newbie questions within the C++ Programming forums, part of the General Programming Boards category; What are the different between C and C++. aren't they the same ? is it that C++ coding is more ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    77

    Some newbie questions

    What are the different between C and C++. aren't they the same ? is it that C++ coding is more complex then C or C++ actually have thing like creating a new class ???

  2. #2
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    C++ can be seen as an extension on C. This extension makes it possible to do object orientented programming in a more easy and powerful way. Both can be used to write very simple or very complex software.

  3. #3
    Registered User
    Join Date
    May 2002
    Posts
    6

    Another noob question, I'll just use the same thread.

    From part one of the tutorial:

    Code:
    #include <iostream.h>
    int main()
    {
      int thisisanumber;
      cout<<"Please enter a number:";
      cin>>thisisanumber;
      cout<<"You entered: "<<thisisanumber;
      return 0;
    }
    I'm using Bloodshed Software's Developmental C++. When I run this code, it ask for a number, but after one is typed in the screen quickly flashes away before I can see the "you entered" part. I asked a similar question a few weeks about the "Hello world!" code because the same problem happened, I never even got to see the window appear, it just quickly flashed onto the screen then vanished again. Somebody told me to type in cin.get() at the end of the code, which worked perfectly. However, I tried to use the same solution with the above code, and the same thing happens again, I'm asked the number, I type one in, and the screen flashes away quickly.

    I'm wondering, does my compiler suck, is that the problem here? Because if not, why wouldn't the tutorial have had the cin.get() part (by the way, what is that "part" called? A command?) in the first place? For every example I've tried in the tutorial I've had the same problem.

  4. #4
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    You have to use
    Code:
    system("PAUSE");
    before the return 0.

  5. #5
    Registered User
    Join Date
    May 2002
    Posts
    6
    Thanks.

    But why didn't the tutorial put that in?

  6. #6
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    Because the tutorial uses Microsoft Visual C++, which doesn't need that, while the Bloodshed Dev-C++ needs that.

  7. #7
    Registered User
    Join Date
    May 2002
    Posts
    6
    Oh wait, the system pause didn't work, I got this message:

    Code:
    implicit declaration of function `int system(...)'

  8. #8
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    You'll have to include some kind of file, forgot which on it is. Try either including conio.h, stdio.h, stdlib.h, and time.h files and see what happens.

  9. #9
    Registered User
    Join Date
    May 2002
    Posts
    6
    Thanks.

    You know, this board is pretty tolorant of noobs and their noobishly noobish questions.

  10. #10
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    Yea, but remember, if you post code, use the code tags, or else you will get flamed really fast

  11. #11
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    yay, another person using Dev-C++!

    I hope you aren't using Dev-C++ 5 Beta, if so, delete from your computer and install Dev-C++ 4. 5 is still in beta, so do NOT do anything serious in that, because it could screw up, since it is BETA. Allegro don't work in version 5 either.

    And for system("PAUSE"); you must type this line in at the top of your source.

    Code:
    #include <dos.h>
    I remembered that, because Dev-C++ has a crappy way to handle getch(), it works like cin. If you don't want the press any key to continue to be displayed type >NUL before the second quotation mark.

  12. #12
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    Actually, the version 5 beta does work well with Allegro, 5.3 beta anyways. I've got it set up correctly for use...but not with MSVC++.

  13. #13
    Shadow12345
    Guest
    I like sex

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory handling functions (newbie questions)
    By PaulBlay in forum C Programming
    Replies: 6
    Last Post: 03-10-2009, 07:37 AM
  2. newbie questions
    By raptorx in forum C Programming
    Replies: 2
    Last Post: 10-10-2007, 10:30 PM
  3. Im a newbie to C and i have some questions
    By pave1104 in forum C Programming
    Replies: 5
    Last Post: 07-05-2006, 10:48 PM
  4. Real newbie with VC6 questions
    By MagiZedd in forum Windows Programming
    Replies: 8
    Last Post: 10-15-2001, 09:27 PM
  5. newbie questions again
    By dune911 in forum C++ Programming
    Replies: 2
    Last Post: 09-14-2001, 03:43 PM

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