Thread: loop-- not sure whats wrong

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    106

    Unhappy loop-- not sure whats wrong

    Im making a loop from the tutorials and I enter it into my compiler,and no matter what I do it doesn't seem to work..

    Code:
     #include <iostream>
    using namespace std;
    int main()
    {
        for ( int x = 0; x < 10; x++ ) {
            cout<< x <<end1;
        }
        cin.get();
    }
    thanks,

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    How does it not work?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    106
    Quote Originally Posted by laserlight View Post
    How does it not work?
    its givng me two error messages which I have learned can throw you completely off when using Dev C++

    It says one in the "int main()" function
    and then it says that end1 is undeclared first use this function

    and to me when I removed all the comments from the other program they look exactly the same... and the other one compiles fine... I'm used to python so preprocessors and everyhting is new to me....

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by jamort
    It says one in the "int main()" function
    and then it says that end1 is undeclared first use this function
    You might want to post the actual text of the error messages. That said, from what you have described, I believe that you mistakenly wrote end1 (as in "end" "one") rather than endl (as in "end" "lowercase L", which can read as "end line").
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    106
    Quote Originally Posted by laserlight View Post
    You might want to post the actual text of the error messages. That said, from what you have described, I believe that you mistakenly wrote end1 (as in "end" "one") rather than endl (as in "end" "lowercase L", which can read as "end line").
    thanks, my mistake that was the problem they appear exactly the same

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. loop the loop - feeling foolish
    By estos in forum C Programming
    Replies: 2
    Last Post: 04-07-2007, 02:45 AM
  2. Replies: 1
    Last Post: 10-27-2006, 01:21 PM
  3. I need help as soon as possible.
    By hyrule in forum C++ Programming
    Replies: 7
    Last Post: 11-09-2005, 05:49 PM
  4. What is wrong with my while loop?
    By aspand in forum C Programming
    Replies: 3
    Last Post: 06-19-2002, 12:07 PM
  5. Whats wrong w/ my loop?? Please help?
    By aspand in forum C Programming
    Replies: 6
    Last Post: 05-30-2002, 03:42 AM