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.
[01:19 pm]
Vrael -- IM GONNA MANUFACTURE SOME SPORTBALL EQUIPMENT WHERE THE SUN DONT SHINE BOY
[01:35 am]
Ultraviolet -- Vrael
Vrael shouted: NEED SOME SPORTBALL> WE GOT YOUR SPORTBALL EQUIPMENT MANUFACTURING
Gonna put deez sportballs in your mouth
[2024-5-01. : 1:24 pm]
Vrael -- NEED SOME SPORTBALL> WE GOT YOUR SPORTBALL EQUIPMENT MANUFACTURING
[2024-4-30. : 5:08 pm]
Oh_Man -- https://youtu.be/lGxUOgfmUCQ
[2024-4-30. : 7:43 am]
NudeRaider -- Vrael
Vrael shouted: if you're gonna link that shit at least link some quality shit: https://www.youtube.com/watch?v=uUV3KvnvT-w
Yeah I'm not a big fan of Westernhagen either, Fanta vier much better! But they didn't drop the lyrics that fit the situation. Farty: Ich bin wieder hier; nobody: in meinem Revier; Me: war nie wirklich weg
[2024-4-29. : 6:36 pm]
RIVE -- Nah, I'm still on Orange Box.
[2024-4-29. : 4:36 pm]
Oh_Man -- anyone play Outside the Box yet? it was a fun time
[2024-4-29. : 12:52 pm]
Vrael -- if you're gonna link that shit at least link some quality shit: https://www.youtube.com/watch?v=uUV3KvnvT-w
[2024-4-29. : 11:17 am]
Zycorax -- :wob:
[2024-4-27. : 9:38 pm]
NudeRaider -- Ultraviolet
Ultraviolet shouted: NudeRaider sing it brother
trust me, you don't wanna hear that. I defer that to the pros.
Please log in to shout.


Members Online: Roy