Tutorial on How to have fun with TC in class

mayjune's Avatar author of Tutorial on How to have fun with TC in class
This is an article on Tutorial on How to have fun with TC in class in C.


A lot of us use TC in our colleges.
Today I will share with you Two ways to have fun in lab with your teachers.


Trick I

In the first way, you will create an error in any wokring code just by adding one or more numeric letter in it. There will be only one error but on every line. Confused?
Ok lets begin, to keep things simple I am using a simple code, but you can this method with any code you like.

void hello();

int main()
    printf ("Hi, My name is ");

    return 0;

void hello()
     printf ("Mayjune :)");
}                                                            //123
As you can see the code is simple and if you have typed it in TC or copied it. Just run it as it is, and it will run.

Now, to generate error remove the // from //123 and let only 123 be there.
Goto to any line where you want to generate error in. Run. Volla. You will get an error saying "Declaration Terminated Incorrectly" in a perfectly working code.

How to fool your teachers?
Well, Just put that 123 out of visible screen space by putting lot of tabs before it so that when you see the code you cant see 123!! Just goto something like int x; or printf ("Hello"); and run, your teacher will surely get confused, why is this code not working??
When I had discovered this fault, I thought i'll have some fun, so i generated error and I was like Mam, somethings wrong!! She spent half an hour, looking at my code (it was a huge code) she had no clue whats wrong!! Finally I told her, I was having fun, I found this error in TC. She laughed and went....

Trick II

The second Trick is more specific, it will work only on this type of code. The value of a variable will change on its own without using any code!!
int main()
   int i,x1[10], y1[10], n;
   printf ("Enter number of vertices : ");
   scanf ("%d", &n);
   return 0;
  int acceptpoly(int x1[], int y1[], int n)
    int i;
    for (i = 0; i < n; i++)
     printf ("Enter x%d and y%d :");
     scanf ("%d %d", x1[i], y1[i]);
    return n;
The code is fairly simple. Its accepting the number of vertices and then the co-ordinates.
Ok. Lets Run this program, lets have n = 3. The program will keep asking you enter x and y for 99% of the time greater then 3. Weird Isn’t it.
Why? Well technically, this program shouldn’t be compiled at the first place. If you notice, while calling acceptpoly() we have sent two parameters but the function is accepting three parameters x, y, n
If you debug it, after you do first scanf ("%d %d", x1[i], y1[i]);
the value of n will change to anything garbage. Before that it will remain to its original value. Its very strange, but then again it shouldn’t happen at all.

Note –
1) In Trick 1, do not use characters only use numbers, else error will show only on that line!!!
2) Trick 2 will not work with void return type. It catches the error, or if you have declared the prototype of the function.
3) All these tricks work with TC 3.0 It May not work with other versions and most probably won’t work with other compilers.

These bugs were found by me, I hope you Enjoy it and also You can see how crappy TC is. Quit using TC. Start using ANSI Standard Compliers like
(*) GCC
(*) Microsoft VC++ Express (2008 or 2005)
(*) OpenWatcom C/C++ Compiler
(*) Digital Mars C/C++ Compiler
(*) BloodShed DevC++ Compiler
(*) MinGW32
(*) DJGPP etc .. (List Compiled By Saswat)

shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Nominate this article for Article of the month - Jul 2009
Raj08's Avatar
hehehe, really nice article for teasing teachers, thanks my dear friend, BUT gone are those days. Missing them a lot.
mayjune's Avatar, Join Date: Jun 2009
Invasive contributor
Thanks... it was nice fun when i did this on my teachers , you can find your own ways to trouble your boss or someone higher to you