Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Stupid Noob in C++ be me, help me out?  (Read 3663 times)

0 Members and 1 Guest are viewing this topic.

dirt1996

    Topic Starter


    Rookie

    Stupid Noob in C++ be me, help me out?
    « on: March 01, 2009, 06:12:01 PM »
    I am new to C++ having switched over from batch.  I am trying to make a number counter to, but dont seem to be having much luck.  Every time i try to compile it says i have an expression syntax error.  Dont give me a new program, just tell me what is wrong with mine.

    #include <iostream>

    using namespace std;

    int main()
    {
      int tminus;

      cout<< "Please enter number to count to"; 
      cin>> tminus;
      cin.ignore();
        for ( int x = 0; x <= << tminus <<; x++ ) {
          cout<< x <<endl;
        }
      cin.get();
    }

    thanks in advance.
    Again, please dont harass couse its something obvious.  Im new okay? :P

    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: Stupid Noob in C++ be me, help me out?
    « Reply #1 on: March 01, 2009, 09:37:28 PM »
    the loop:
    Code: [Select]
        for ( int x = 0; x >= tminus ; x++ ) {
          cout<< x <<endl;
        }


    too many << operators... I would guess you picked those up from batch lol  ;D
    I was trying to dereference Null Pointers before it was cool.

    dirt1996

      Topic Starter


      Rookie

      Re: Stupid Noob in C++ be me, help me out?
      « Reply #2 on: March 02, 2009, 05:53:44 AM »
      thank you so much! :o

      dirt1996

        Topic Starter


        Rookie

        Re: Stupid Noob in C++ be me, help me out?
        « Reply #3 on: March 02, 2009, 06:37:30 AM »
        the loop:
        Code: [Select]
            for ( int x = 0; x >= tminus ; x++ ) {
              cout<< x <<endl;
            }


        too many << operators... I would guess you picked those up from batch lol  ;D
        but how do i fix this? ???

        BC_Programmer


          Mastermind
        • Typing is no substitute for thinking.
        • Thanked: 1140
          • Yes
          • Yes
          • BC-Programming.com
        • Certifications: List
        • Computer: Specs
        • Experience: Beginner
        • OS: Windows 11
        Re: Stupid Noob in C++ be me, help me out?
        « Reply #4 on: March 02, 2009, 09:13:09 AM »
        Code: [Select]
        count << x << endl;
        I was trying to dereference Null Pointers before it was cool.

        dirt1996

          Topic Starter


          Rookie

          Re: Stupid Noob in C++ be me, help me out?
          « Reply #5 on: March 02, 2009, 11:42:18 AM »
          Can you put it in the code for me.  So the loop part isnt necessary is what ur saying?  Again I am so sorry for being difficult :(

          BC_Programmer


            Mastermind
          • Typing is no substitute for thinking.
          • Thanked: 1140
            • Yes
            • Yes
            • BC-Programming.com
          • Certifications: List
          • Computer: Specs
          • Experience: Beginner
          • OS: Windows 11
          Re: Stupid Noob in C++ be me, help me out?
          « Reply #6 on: March 02, 2009, 11:50:30 AM »
          that would just be the one line- I believe the reason it isn't working is the lack of spaces

          Even with that one line I typo'd  ::)


          Code: [Select]
          #include <iostream>

          using namespace std;

          int main(int argc, char* argv[])
          {
            int tminus;

            cout << "Please enter number to count to:";
            cin >> tminus;
            cin.ignore();
              for ( int x = 0; x <= tminus ; x++ ) {
                cout << x <<endl;
              }
            cin.get();
          }

          that code compiles and runs with Microsoft Visual C++ 6.
          I was trying to dereference Null Pointers before it was cool.

          dirt1996

            Topic Starter


            Rookie

            Re: Stupid Noob in C++ be me, help me out?
            « Reply #7 on: March 02, 2009, 08:42:07 PM »
            Sorry for being stupid, thank you so much!