super newbie

This is a discussion on super newbie within the C++ Programming forums, part of the General Programming Boards category; well hi there i have a stupid question i am studiyng/learning the tutorial on this site and i tried all ...

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    7

    Arrow super newbie



    well hi there
    i have a stupid question
    i am studiyng/learning the tutorial on this site and i tried all sorts of compilers but none of theme work on a simple program:

    #include <iostream.h>
    int main()
    {
    int blaat;
    cout<<"hoi plzz press a number";
    cin>>blaat;
    cout<<"dit nummer??:"blaat;
    cout<<"ok";
    return 0;

    the best compiler and the easist is dev c++
    but it gives 20 errors or something like:
    << /*that isnt right and*/ return 0

    it looks like the tutorial is a dialect or somethinhg

    plzzz help me
    i want 2 learn c++
    instead of pascal
    Last edited by kamikadam; 08-04-2004 at 02:54 PM.

  2. #2
    Registered User
    Join Date
    Jul 2004
    Posts
    101
    First you should test that your compiler is installed correctly. You can do so with the following two programs. The first is standard C++ for modern compilers and the second is pre-standard C++ for older compilers.
    Code:
    #include <iostream>
    
    int main()
    {
      std::cout<<"Test"<<std::endl;
    }
    Code:
    #include <iostream.h>
    
    int main()
    {
      cout<<"Test\n";
      return 0;
    }
    If neither of these work then the problem is likely a bad installation or configuration. If one or both of them compiles then the problem is an error in your code.

  3. #3
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    well theres several problems in your code. I dont see an ending bracket and you are printing your number out wrong.

    Code:
    #include <iostream.h> 
    
    int main()
    {
      int blatt;
    
      cout << "Enter a number: ";
      cin >> blatt;
    
      cout << endl; //skip a line
    
      cout << "Your number is " << blatt;
    
      return 0;
    }

  4. #4
    Registered User
    Join Date
    Aug 2004
    Posts
    7
    ok ty Princeton and Vicious
    what princeton said was the good thing
    but i have 1 question remaining:
    does someone now a good tutorial for c++ wich is up to date and working properly on dev c++

    and ty alll for your posts/help

  5. #5
    Registered User
    Join Date
    Jul 2004
    Posts
    101
    I have found this tutorial to be an excellent start.

  6. #6
    Registered User
    Join Date
    Aug 2004
    Posts
    7
    Quote Originally Posted by Princeton
    I have found this tutorial to be an excellent start.
    ty but what is that "std" thing
    because in a lot of older tutorials you didnt need it .
    is it new or something?? and
    using namespace std;
    will prevent you from constantly typing this?:
    std::cout<<"nou zeg "<<std::endl;


    thnx in advance
    i am going 2 bed now works awaits tommorow early

  7. #7
    Registered User
    Join Date
    Jul 2004
    Posts
    101
    >>but what is that "std" thing
    std is a namespace. Namespaces are basically boxes that keep you from mixing up all of your stuff. Instead of saying "use whichever X you find first" you can now say "use the X in the Y box". This solves some rather irritating problems in larger projects where two or more libraries use the same names, but it also means that everything in the standard library is in the std namespace and must now be qualified by saying <namespace>::<name>.

    >>because in a lot of older tutorials you didnt need it
    Pre-standard C++ did not support namespaces so you will not see them in older code. Despite the apparent convenience of that, it is better to use the newer and more powerful standard library.

    >>using namespace std;
    >>will prevent you from constantly typing this?:
    There are three ways to qualify names in a namespace. The first is the most direct; you simply qualify a name with its namespace with every use.
    Code:
    std::cout<<"A"<<std::endl;
    std::cout<<"Test"<<std::endl;
    The second approach is to qualify a specific name for the scope in which you plan to use it. Then you can avoid having to qualify every use of the name within the regions of that scope. Those names that are not qualified in this way must still be qualified directly.
    Code:
    using std::cout;
    
    cout<<"A"<<std::endl;
    cout<<"Test"<<std::endl;
    The third and final method is to qualify all names in a namespace with a single command. This is the most convenient way but also the most dangerous as it effectively removes the protection of namespaces within the scope of its effect. All names within the namespace can now be used unqualified.
    Code:
    using namespace std;
    
    cout<<"A"<<endl;
    cout<<"Test"<<endl;
    Which method or combination of methods you use is up to you. Different people have different preferences.

  8. #8
    Registered User
    Join Date
    Aug 2004
    Posts
    7

    Thumbs up

    i realy owe you 1 princeton
    realy
    now i canmove on to learn c++
    thnx again

  9. #9
    Registered User
    Join Date
    Jul 2004
    Posts
    98
    @ kamikadam :

    I am a newbie too,maybe my answer is stupid ,forgive me.
    I think this statement maybe some error:

    cout<<"dit nummer??:"blaat;
    maybe should change like this:
    Code:
    cout<<"dit nummer??:"<<blaat;   //insert one "<<"

  10. #10
    Registered User
    Join Date
    Aug 2004
    Posts
    7
    Quote Originally Posted by toysoldier
    @ kamikadam :

    I am a newbie too,maybe my answer is stupid ,forgive me.
    I think this statement maybe some error:



    maybe should change like this:
    Code:
    cout<<"dit nummer??:"<<blaat;   //insert one "<<"

    you are right indeed
    i made a mistake i could have knew that but i am a bit sloppy
    sometimes
    but ty

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ newbie / linux not so newbie question
    By goldmonkey in forum C++ Programming
    Replies: 7
    Last Post: 12-13-2003, 12:27 PM
  2. With super powers would you:
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 09-18-2003, 12:27 AM
  3. Post Super Bowl predictions here!
    By PJYelton in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 01-23-2003, 10:13 PM
  4. Which super hero(ine) are you?
    By biosninja in forum A Brief History of Cprogramming.com
    Replies: 21
    Last Post: 10-15-2002, 07:36 AM
  5. Newbie Game Develpoers Unite!
    By Telenosis in forum Game Programming
    Replies: 10
    Last Post: 06-22-2002, 03:02 PM

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