Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Sunday, November 27, 2011

Shrinking the C code !

One of my friends  ,asked me to write a C program that will reverse and print the words in a file with minimum number of lines. Our intention was to create a program that will be of minimum size. Below is  my solution to the question.



My question to the readers would be , can you develop something shorter than this? If so feel free to post it out.
 So the above code is gnu99 standard , now let us try the c99 standard. Below is the code..


Noted the difference?? Well , here I have declared variable i as a character and have used it as an integer afterwards! For the integers between -128 to +126 ,character declaration will do. Even though this is not a rocket science , most students are unaware of it.