|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Member (9 bit)
Join Date: Sep 2006
Location: NYC
Posts: 272
|
Trying to do Matrixy Text in C++
While we were doing loop demos in class (HS C++ Half-year course), me and my friend found that if you set the loop number (middle section) to more than a couple thousand, it'll keep running text over the screen up and down.
Well, I was just trying to do this at home and Idk if I did it right. It'll just print it once. The main thing I'm getting at is that I want a constant flow of numbers and letters just for kicks to look cool. Here's the code I just made in Visual C++: I think I got some of the Loop code wrong. Help me out if you can guys .#include #include int main (void) { int x; { for (x=1 ; x>=2000000; x+=1); cout<<"1 2 3 4 5 "<<(endl; I CAN"T DO THIS ON FORUMS CAUSE IT JUST SKIPS LINE -->BASICALLY ENDL ![]() } return 0; } Last edited by Sam-U-Rai; 03-02-2007 at 05:20 PM. |
|
|
|
|
|
#2 |
|
Moderator
Staff
Premium Member
Join Date: Aug 2003
Location: Richmond, VA
Posts: 7,835
|
The for loop should have its own scope - you have the starting bracket before the for statement. In short, it should be something like:
PHP Code:
kram
__________________
"For today, goodbye. For tomorrow, good luck. And forever, Go Blue!"
University of Michigan President Mary Sue Coleman |
|
|
|
|
|
#3 |
|
Member (11 bit)
|
I believe this is what your trying to do. I made 2 loops. Just pick one. Though the "for" loop will eventually end, the "while (true)" will continue on until you close the window. btw, i commented out the loops so just remove the "//" when you write it. And just a note, you should not put "void" in the parameters for "main", and try not to use any includes if you dont need them...iomanip for example. Also, you can scrap the "return 0;" and finally, when you using a "for" loop it makes for cleaner code to make and initialize the variable in the parameters of the loop.
Edit: one more thing (sorry if im a little to much, just want to try to help with your code.) you dont need the "{" blocks in a loop unless its more then one line (though its fine if you do have them), and scrap the ";" at the end of the "for" loop. Finally, you have one the blocks in the wrong place. You would need one to open main and one to close, if you used it on the "for" loop you would need one right after the ")" on the "for" and one at the end of the loop. Last edited by FLG; 03-03-2007 at 12:08 AM. |
|
|
|
|
|
#4 | |
|
Member (9 bit)
Join Date: Feb 2005
Posts: 392
|
Quote:
errrr........... I think u got the condition wrong in the "for loop" with x>=20000000 <------loop stops at printing one line because condition is met! should be x<=20000000 instead. <-----will print 20000000 lines before ending. however, it would look better if the program runs infintely until a input is read, much like FLG's infinte while loop, one post above this post.
__________________
words to live by: others don't know, I know. others know, I know more. others know more, I excel. one shouldnt read this far; above, is meant as an encouragement, translated from a Chinese Proverb. "He who angers you conquers you." : Elizabeth Kenny Last edited by alfie2; 03-03-2007 at 05:44 AM. |
|
|
|
|
|
|
#5 | |
|
Member (9 bit)
Join Date: Sep 2006
Location: NYC
Posts: 272
|
Quote:
Thanks for the help! I changed it and now its doing it completely. Hell yeah, thank you guys. |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Firefox text size increase affects menu bar and ads | Londoner | Internet, Web Applications, & The Cloud | 4 | 02-19-2007 02:28 PM |
| Text Message | EFG Tech | Windows Tips, Tricks, and Tweaks | 2 | 06-05-2006 06:38 AM |
| Focus or tracking error | nokiafan05 | Computer Hardware | 0 | 02-15-2006 10:19 PM |
| Burrner randomly shooting duds - Please Help! | Zac3010 | Computer Hardware | 18 | 04-20-2004 09:40 PM |
| I can't BURN>>>> | john ranger | Windows Legacy Support (XP and earlier) | 24 | 05-15-2003 01:51 PM |