Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Learning to program in visual c++ 2008 express

  • 22-03-2009 3:08pm
    #1
    Registered Users, Registered Users 2 Posts: 2,318 ✭✭✭


    This is the code i've been trying to get to work in visual c++ 2008 express edition. Could someone please tell me where I went wrong. Could be miles off as only learning it a day or two now.

    #include <iostream>
    using namespace std;

    int main ()
    {
    cout << "Comment 1" << endl;
    cout << "Comment 2" << endl;

    for (int i = 0; i < 10; i++)

    <<
    cout << i;
    >>



    system("pause");
    }


Comments

  • Closed Accounts Posts: 1,567 ✭✭✭Martyr


    [PHP]for (int i = 0; i < 10; i++)

    <<
    cout << i;
    >>[/PHP]

    the problem is there.


  • Registered Users, Registered Users 2 Posts: 2,318 ✭✭✭deceit


    Thanks, I tried this and it seems to work:

    #include <iostream>
    using namespace std;

    int main ()
    {
    cout << "Comment 1" << endl;
    cout << "Comment 2" << endl;

    for (int i = 0; i < 10; i++)

    cout << i << endl;

    system("pause");
    }


  • Registered Users, Registered Users 2 Posts: 26,584 ✭✭✭✭Creamy Goodness


    for your for loops you really should use {} for the statements you want to loop

    for eg.
    for(int i = 0 ; i < 10 ; i++)
    {
        cout << i << endl;
    }
    

    the following will work but if you need two or more statements done in a loop you need { }
    for(int i = 0 ; i < 10 ; i++)
        cout << i << endl;
    


  • Registered Users, Registered Users 2 Posts: 2,318 ✭✭✭deceit


    for your for loops you really should use {} for the statements you want to loop

    for eg.
    for(int i = 0 ; i < 10 ; i++)
    {
        cout << i << endl;
    }
    

    the following will work but if you need two or more statements done in a loop you need { }
    for(int i = 0 ; i < 10 ; i++)
        cout << i << endl;
    

    Thanks, thats alot of help :).


  • Closed Accounts Posts: 2,219 ✭✭✭Lab_Mouse


    You will also find at the start a few of your problems will stem from typo's either forgetting semi colons or curly brackets.Some times these throw up strange error reports(not nessarily 'your missing a ';'!)

    compile your code regularily(even every couple of lines of code at the start till your confident of your syntax) because i found if i didnt i could end up with nearly 30 errors,which i found daunting to go back and fix.

    and enjoy the coding!


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 26,584 ✭✭✭✭Creamy Goodness


    also to add what lab_mouse said, compilers often single out a line of code where the error is e.g.: Error on line 43.

    always check the line above as it possible that an error on line 42 may be causing the error.


Advertisement