What am I doing wrong (for fun)
by Michael Perry · in Technical Issues · 07/17/2007 (11:25 am) · 8 replies
Writing a new game engine, and I'm testing out some coding concepts I've never heard of. Thought I'd try them in a simple main loop first...something is going really wrong...
Suggestions?
#include <iostream>
using namespace std;
void main()
{
goto start;
start:
for(int i = 0; i < 9999; i++)
char* x = new char[9999];
goto middle;
middle:
int* YyysIIlkk;
int bob = *YyysIIlkk +3;
goto end;
end:
// End of application =)
}Suggestions?
About the author
Programmer.
#2
07/17/2007 (11:49 am)
Thirdly, you're using goto, which is evil.
#3
Doh, beat to it and I missed the deleting.
07/17/2007 (11:50 am)
I'm gonna go with YyysIIlkk is pointing to nothing and will crash when its bob is assigned to it plus 3.Doh, beat to it and I missed the deleting.
#4
I'm kind of confused about what coding concepts this is demonstrating. Massive allocation of unreferenced memory, random goto's, and dereferencing of unassigned pointers. This must be an entry for a coding competition I am not aware of.
07/17/2007 (11:57 am)
Hmmm, well the compiler should catch the 'YyysIIlkk' not being initialized. If it has garbage memory assigned to it, though, than dereferencing it should cause an access violation. If it doesn't, than the value of bob is undefined (well I guess undefined +3).I'm kind of confused about what coding concepts this is demonstrating. Massive allocation of unreferenced memory, random goto's, and dereferencing of unassigned pointers. This must be an entry for a coding competition I am not aware of.
/*
* Program to compute an approximation of pi
* by Brian Westley, 1988
* (requires pcc macro concatenation; try gcc -traditional-cpp)
*/
#define _ -F<00||--F-OO--;
int F=00,OO=00;
main(){F_OO();printf("%1.3f\n",4.*-F/OO/OO);}F_OO()
{
_-_-_-_
_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_
_-_-_-_
}There, try that one...
#5
Pi == 3; // Exactly equal to
Right?
*Edit*- On a side note...that is an awesome chunk of code Pat =)
07/17/2007 (12:03 pm)
Why would you need to compute an approximation of pi?Pi == 3; // Exactly equal to
Right?
*Edit*- On a side note...that is an awesome chunk of code Pat =)
#6
07/17/2007 (1:27 pm)
Well that program just doesnt make any sense whatsoever. =)
#7
I like how they do nothing and mean less.
a Real instantiation of fugly code.
07/17/2007 (1:47 pm)
Lol, those goto's are funny.I like how they do nothing and mean less.
a Real instantiation of fugly code.
Torque 3D Owner Sean H.