Mohan S N wrote:
> Sorry to be a nit-picker but this code is tough to read.
> See below.
>
> --- sairam ram <[EMAIL PROTECTED]> wrote:
>
>> thanks to all .please send to me more programes
>>
>> --- dhaval shah <[EMAIL PROTECTED]> wrote:
>>
>
> Absolutely no newlines anywhere: between includes, defines, even
> function declarations or start of main(). Why??
>
>>> #include<stdio.h>
>>> #include<conio.h>
>>> #define N 5
>>> int top=-1,i,x;
>
> You really don't need x and i to be globals.
>
>>> void push(int s[N]);
>>> void pop(int s[N]);
>
> Could be useful to have pop() return the value popped.
>
>>> void peep(int s[N]);
>>> void change(int s[N]);
>
> Quite dubious to have these two functions.
>
>>> void dis(int s[N]);
>
> Why not void display(int s[N])?
> I have to scratch my head to find out what "dis" means.
>
>>> void main()
>>> {
>>> int x=1,s[N];
>
> Indentation: Only one space. Please use one TAB or 4/8 spaces uniformly
> throughout the code. This makes it much clearer to understand when one
> new level of control structure (if/else,while,...) is entered.
I use two-spaces (uniformly). If, for no other reason, to drive people
like you nuts. I consider my code to be beautiful and elegant:
http://headrush.typepad.com/creating_passionate_users/2006/03/code_like_a_gir.html
I was tempted to say something before, but the original code lacked not
only good style (as you so kindly pointed out) but also good programming
design. I just didn't feel it was worth pointing out every last flaw in
the code - among other reasons: It has to be the worst implementation
of a stack I've seen in a long time (every single line has at least one
problem). It feels like something an interviewer would ask: "What is
wrong with this code?" I decided to let someone else tear it apart. I
give the original code a F--:
http://www.homestarrunner.com/sbemail110.html
--
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197
*NEW* MyTaskFocus 1.1
Get on task. Stay on task.
http://www.CubicleSoft.com/MyTaskFocus/