jakabjr wrote:ok, a few questions about this:
is there a reason for using (2==t)
Heard about best practices?This is a case in point.You can easily screw up
the whole thing if you miss one character when put in a condition as in:
the compiler doen't catch this and you go nuts over one damn
stupid bug!OTOH, put 2 in the LHS, and do the test, here 2, a numeric literal can
never be a lvalue(an address, that is, for most cases)and the compiler cribs.
jakabjr wrote:
and for(...;++i) ...and for(...;i++)? I've seen this used, don't really know why, originality

?
For most purposes its a matter of style, in C.Though there are(or used to be) some compiler/system pair where the former could be directly translated to a single machine instruction, and the latter could not be.
It makes a difference in C++, when its overloaded for some object, where the postfix takes more time because it requires some extra ops.
But that's really off-topic here(in other words, I'll leave that as an exercise for you to find out!Google, google and google more)
can u use sizeof without ()?
Yes, sizeof is an operator, not a function.See K&R.
suggestions:
using typecast before malloc gets rid of compiler warnings;
Yes.But that's flirting with danger.You don't want the compiler to shut up, rather scream at you.That's the compiler's job.So make it a little easy on the poor chap.Also malloc returns a void *, which due to C's inherent implicit-type-conversion-black-magic-for-void can be converted to almost anything without your forcing it down its neck.
BTW: standard C, and conforming compilers will never ever tell you to do that, trust me.
the string in scanf "%d %d" should be "%d%d" (without space), which is redundant, not necesarry there, since %d consumes all blanks;
Yes, but that is a style issue, some people like me, think its more readable, some think its more confusing(and/or the other group doesn't know his C as well

)...so let each be happy with his own idiosyncrasies.
Actually putting spaces helps me count faster how many I've put in when the input is supposed to read in some 4, 7, 8 items at a time - without my specs, of course.
That is one heck of a post!Flames welcome,
Suman.