Staredit Network > Forums > Technology & Computers > Topic: The wiggly worm
The wiggly worm
Apr 22 2009, 4:02 am
By: omginbd  

Apr 22 2009, 4:02 am omginbd Post #1



I was bored, and I'm learning C++ and I decided to make the wiggly worm. For the skeptical:
(Keep in mind white space doesn't transfer so the you don't really get the idea from the source)
Quote from Source Code
//Mah firzt
#include <iostream>
#include <cstdlib>

using namespace std;

int x;

int main()
{
while (x < 500)
{
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;

cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;

cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;

cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;

cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;

cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;

cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;

cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;

cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;

system("cls");
x++;
}
cin.get();
}


Attachments:
Wiggly worm.exe
Hits: 12 Size: 575.58kb



None.

Apr 22 2009, 4:04 am Falkoner Post #2



You shoulda put some sleeps in there, it doesn't show it long enough as is.

Not to mention, why did you spam the couts? Brute-forcing is the thing you want to avoid in C++, use a loop for things like that.



None.

Apr 22 2009, 4:35 am omginbd Post #3



Quote from Falkoner
You shoulda put some sleeps in there, it doesn't show it long enough as is.

Not to mention, why did you spam the couts? Brute-forcing is the thing you want to avoid in C++, use a loop for things like that.

Did I not use a loop? I think I know what you mean, but it's better than doing:
Quote from Source
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;

cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;

cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;

cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;

cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;

cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;

cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;

cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;

cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
cout << " ||" << endl;
That and just copy and pasting it 500 times lol.



None.

Apr 22 2009, 4:36 am stickynote Post #4



Lol, you can use a loop, and add to a variable each time until the variable is too large for the condition.



None.

Apr 22 2009, 1:53 pm ClansAreForGays Post #5



I get the feeling you actually don't know what a loop is, or at least what you can do with it.




Apr 22 2009, 10:13 pm Centreri Post #6

Relatively ancient and inactive

It can be done with maybe 1/20 the space, but I suppose it works...



None.

Apr 22 2009, 10:43 pm Falkoner Post #7



What I mean by using a loop is that instead of doing:
Quote
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;

You could have instead done:
Code
for(int loops = 0; loops < 10; loops++)
{
    cout << "||\n";
}




None.

Apr 23 2009, 12:04 am Jello-Jigglers Post #8



Quote from Falkoner
What I mean by using a loop is that instead of doing:
Quote
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;

You could have instead done:
Code
for(int loops = 0; loops < 10; loops++)
{
    cout << "||\n";
}
Haha ya but for this silly of a program it doesn't matter.

also, careful with system"cls', actually avoid system altogether if you can. It can lead to vulnerabilities.



None.

Apr 23 2009, 3:36 am Falkoner Post #9



Quote
also, careful with system"cls', actually avoid system altogether if you can. It can lead to vulnerabilities.

I've found that the main issue with system commands is that they are geared for C commands, not C++, and will actually skip code like cout unless there's an endl.



None.

Apr 23 2009, 3:48 am omginbd Post #10



Nothing else works with DevC++ to clear screen/pause. :bleh:



None.

Apr 23 2009, 3:58 am Jello-Jigglers Post #11



Quote from Falkoner
Quote
also, careful with system"cls', actually avoid system altogether if you can. It can lead to vulnerabilities.

I've found that the main issue with system commands is that they are geared for C commands, not C++, and will actually skip code like cout unless there's an endl.
Or cin.ignore() works, but you only use it when you find you're actually skipping code.



None.

Apr 23 2009, 12:39 pm EzDay281 Post #12



Quote
Haha ya but for this silly of a program it doesn't matter.
'Twould be a good habit, though, and really, it's what I'd've done just to save myself a few copy pastes. =P



None.

Apr 23 2009, 5:05 pm MrrLL Post #13



Also, with multiple couts, don't forget:

cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;
cout << "||" << endl;

is the same as
Code
cout  << "||" << endl
       << "||" << endl
       << "||" << endl
       << "||" << endl;




None.

Apr 23 2009, 9:17 pm O)FaRTy1billion[MM] Post #14

👻 👾 👽 💪

Quote from omginbd
(Keep in mind white space doesn't transfer so the you don't really get the idea from the source)
Use [code]. There is a reason it exists.



TinyMap2 - Latest in map compression! ( 7/09/14 - New build! )
EUD Action Enabler - Lightweight EUD/EPD support! (ChaosLauncher/MPQDraft support!)
EUDDB - topic - Help out by adding your EUDs! Or Submit reference files in the References tab!
MapSketch - New image->map generator!
EUDTrig - topic - Quickly and easily convert offsets to EUDs! (extended players supported)
SC2 Map Texture Mask Importer/Exporter - Edit texture placement in an image editor!
\:farty\: This page has been viewed [img]http://farty1billion.dyndns.org/Clicky.php?img.gif[/img] times!

Apr 24 2009, 3:51 am Jello-Jigglers Post #15



Quote from O)FaRTy1billion[MM]
Quote from omginbd
(Keep in mind white space doesn't transfer so the you don't really get the idea from the source)
Use [code]. There is a reason it exists.
Thanks.



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[10:13 pm]
Oh_Man -- No APM in chess. Computer just outthinks the human by seeing more moves ahead and more permutations
[10:12 pm]
Oh_Man -- U reckon? Kasparov waa defeated by computer decades ago
[05:47 pm]
NimoStar -- If its any consolation, the human brain would still mop the floor with this bot if it wasn't limited by the mechanical interface
[05:34 pm]
NimoStar -- Well. The bot didn't come up with any new strategy. It just has superhuman micro. Hard to beat that. I reckon even the simplest dedicated chess engines are unbeatable for humans now.
[02:13 pm]
Oh_Man -- all g
[10:54 am]
NudeRaider -- Oh_Man
Oh_Man shouted: NudeRaider did u watch the entire video? it's not one game. it's currently dominating the ladder at number 1 position. do ur research first!
Oops, caught me there, no I haven't. :( I was imagining how the game went. Sorry for that. Watching it now. brb
[10:52 am]
NudeRaider -- NimoStar
NimoStar shouted: They were not "Unprepared" that was their fifth loss in a row against the bot. The other replays are also available
that doesn't mean he was prepared. When humans come around with new strategies it often takes weeks until the pros figure out how to shut it down. Oh_Man that's certainly a way more convincing argument for micro being "too good to beat".
[09:43 am]
DiearAnother -- wirefram
[08:35 am]
NimoStar -- Well, pros showed that long ago... half of zerg pros just ling muta rush
[08:35 am]
NimoStar -- " its shown is that you can trade 1000's of apm to make up for lack of strategy"
Please log in to shout.


Members Online: DarkenedFantasies, Symmetry