typedef does not define a new data type There are three main reasons for using typedefs: * It makes the writing of complicated declarations a lot easier. This helps in eliminating a lot of clutter in the code. * ItContinue reading… More on structures and unions
Author: vamsipavan
Operator Precedence Chart for referance
Operator Type Operator Execution Order Primary Expression Operators () [] . -> expr++ expr– left-to-right Unary Operators * & + – ! ~ ++expr –expr (typecast) sizeof() right-to-left Binary Operators * / % left-to-right + – >> >=
precidence of , and =
#include int main(int argc,char *argvp[]) {
precidence of * and ++
# include main () {
Order of arguments passed to a function
#include void fn (int, int); main () {
Evaluation of If statement
#include main () {
Some Nice Perl Tips
Alias of perl builtin variables ========================================================== use English The English module provides aliases for the Perl builtin variables. $ARG is equivalent to $_ $1 equivalent to $MATCH $` equivalent to $PREMATCH $’ equivalent to $POSTMATCH Locate the source path ofContinue reading… Some Nice Perl Tips
Evaluation sequency of print statement
#!/usr/bin/perl print “Hey! “, mysub(“foo”); sub mysub { my $a=shift; print “$a “; } It outputs: foo Hey! 1 Because print evaluates its rightmost terms first, the “mysub()” is called before the “Hey! ” is printed. That prints “foo” andContinue reading… Evaluation sequency of print statement
Evaluation of if statements
#!/usr/bin/perl my ($x,$a)=(0,1); if ($a || $x++) { print “foon”; } print “$x”; At last, it will print 0 because, during the evaluation of if statement, since $a = 1, the next part of ‘or’ wont be evaluated. So $xContinue reading… Evaluation of if statements
$_ will hold the reference, not the copy of variable
#!/usr/bin/perl @list=qw(one two three); foreach(reverse @list) { print “$_n”; $_=”foo”; } print “$list[0]n”; Finally it will pring ‘foo’ not ‘one’. Because $_ isn’t a copy of the list element, it’s a reference. Modifying it will change the list.