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.
[06:47 am]
NudeRaider -- lil-Inferno
lil-Inferno shouted: nah
strong
[05:41 am]
Ultraviolet -- 🤔 so inf is in you?
[04:57 am]
O)FaRTy1billion[MM] -- my name is mud
[04:35 am]
Ultraviolet -- mud, meet my friend, the stick
[10:07 pm]
lil-Inferno -- nah
[08:36 pm]
Ultraviolet -- Inf, we've got a job for you. ASUS has been very naughty and we need our lil guy to go do their mom's to teach them if they fuck around, they gon' find out
[05:25 pm]
NudeRaider -- there he is, right on time! Go UV! :D
[05:24 pm]
lil-Inferno -- poopoo
[05:14 pm]
UndeadStar -- I wonder if that's what happened to me. A returned product (screen) was "officially lost" for a while before being found and refunded. Maybe it would have remained "lost" if I didn't communicate?
[03:36 pm]
NudeRaider -- :lol:
Please log in to shout.


Members Online: NudeRaider, Roy, 6alicee451yr9, Moose