Public Group

Archived

This topic is now archived and is closed to further replies.

Loop problems!

This topic is 5216 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

So, I finally got past the closing issue. I found out the #include <conio.h> command, which lets me use the getch() command before i return 0. Anyway, so I did some of the programs in a few lessons off of www.cprogramming.com and i'm on the loops lesson. Now, I'll type in the given program and you tell me whats wrong, because it won't let me run the program at all. Even after I compile it, i get a warning that says its not compiled. What am I doing wrong??
#include <iostream.h>
int main()
{
for(int x=0;x<100;x++)
{

cout << x << end1;
}
return 0;
} 

Share on other sites
You could first read the FAQ to get the source right (tip: source tags).
btw: do you get any error messages?
What compiler do you use (VC 7.1 won'accept iostream.h anymore).
And it's endl, not end1 (last letter is a L).

[edited by - VolkerG on May 9, 2004 2:54:20 PM]

Share on other sites
quote:
Original post by DudeManGuy
HOLY POOP!
cout <;<; x <;<; end 1;
imagine that without all the ; except for the one at the end, and all of it squished together!
As I pointed out in your original posts (I removed the others), you can edit your posts. The forum software accepts HTML, so it views "<x" as the beginning of an HTML tag, which is why the rest of the line disappears.

It''s more readable to have a space in between every token (variable identifier, operator, etc) anyway:
#include <iostream>using namespace std; int main(){  for( int x = 0; x < 100; ++x )  {    cout << x << endl;  }  return 0;}
The lines in bold are different from yours. The header <iostream.h> is old and non-standard, so you shouldn''t use it. Use <iostream> (no ".h" extension) instead. The latter places all symbols inside the namespace std. Explaining namespaces in full is tedious, and has been done before. Google or search this site for "C++ namespace".

Share on other sites
I thought it was ENDL, not END1..

--------------------------------
Junaris Games - An Amateur Game Development Team

Current Project: Codename: Orbo
Come support us! It gives us motivation

Share on other sites
quote:
Original post by EQRainer
I thought it was ENDL, not END1...
It is (lowercase, though, and a monotype ''l'' can look like a ''1'': l, 1). What leads you to this question?

Share on other sites
Hehehe, thanks so much, I''ll try it right now

Sorry bout the code thing, I had no idea that it operated that way. Thanks again, and next time I''ll be sure to put it in with spaces.

If you can find me, you will recieve \$1,000,000,000 in cash!!

1. 1
2. 2
JoeJ
20
3. 3
frob
18
4. 4
5. 5

• 10
• 11
• 12
• 13
• 9
• Forum Statistics

• Total Topics
632204
• Total Posts
3004755

×