Posted on September 13, 2007 by awmanoj
A friend (and colleague) in an attempt to have a long discussion asked me about my preference between cascaded if-else and switch-case statements and which one is better. I could get away (because was caught into some work I didn’t want to lose attention from) by saying that I will certainly be getting back with [...]
Filed under: Programming | 3 Comments »
Posted on September 6, 2007 by awmanoj
Read the Epigrams on Programming. One big difference between an expert programmer (and designer) and a naive is the level of idiomization of experience. So my dear programmer – standardize, idiomize. As they say
The only difference (!) between Shakespeare and you was the size of his idiom list – not the size of his vocabulary.
Filed under: Programming | Leave a Comment »
Posted on April 13, 2007 by awmanoj
Q. Difference between __cdecl and __stdcall ?
A. Responsibility of cleaning up of arguments on stack is caller’s in case of __cdecl and is callee’s in case of __stdcall. Default call is __cdecl.
some more points to keep in mind:
> Since __stdcall does stack cleanup, the (very tiny) code to perform this task is found in only [...]
Filed under: Programming | 1 Comment »
Posted on February 14, 2007 by awmanoj
What is the difference between returning from main with some exit code and calling exit giving the exit code as parameter ?
Basically the difference between following programs !
//ret.c
int main()
{
return 43;
}
//exit.c
int main()
{
exit(43);
}
well, there are three ways for the processes to exit: -
1. Voluntary exit (implicit)
2. Voluntary exit (explicit)
3. Involunatary exit
Voluntary exit can be implicit [...]
Filed under: C++, Programming, linux | 1 Comment »
Posted on February 13, 2007 by awmanoj
A nice question, I came through while being in an interview. Well, so how do you make sure that the object can be instantiated only on heap and not on stack ? so, if you are of the kind who don’t think without being given the use and purpose .. well the purpose is that [...]
Filed under: C++, Programming | Leave a Comment »
Posted on January 2, 2007 by awmanoj
From the confusions in Expressions in C, as to what is legal and defined, and what is not, I read following from the C FAQs.
A sequence point is a point in time at which the dust has settled and all side effects which have been seen so far are guaranteed to be complete. [...]
Filed under: Programming, technical | 1 Comment »
Posted on January 2, 2007 by awmanoj
I came across the following C problem this morning. This problems are so similar in looks that i felt a deja vu. I used to think earlier that these problems are just a result of obscure thinking or for the satisfaction of an interviewer’s ego but now my view is different – they also prove [...]
Filed under: Programming, technical | Leave a Comment »
Posted on December 4, 2006 by awmanoj
A friend of mine was asked to write the following program in an interview. He asked me how to do it?
Write a program to reverse the order of the words in a given statement (string). e.g. if input string is “India is a great country”, Output should be “country great a is India”.
This is [...]
Filed under: Programming, technical | 2 Comments »
Posted on December 3, 2006 by awmanoj
Just got hold of this code from a C programming resource. C really makes a good language for obfuscated code – valid programs which ‘look’ crap !
#include >stdio.h<
main(t,_,a)
char *a;
{return!0<t?t<3?main(-79,-13,a+main(-87,1-_,
main(-86, 0, a+1 )+a)):1,t<_?main(t+1, _, a ):3,main ( -94, -27+t, a
)&&t == 2 ?_<13 ?main ( 2, _+1, “%s %d %d\n” ):9:16:t<0?t<-72?main(_,
t,”@n’+,#’/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{n+\
,/+#n+,/#;#q#n+,/+k#;*+,/’r :’d*’3,}{w+K w’K:’+}e#’;dq#’l q#’+d’K#!/\
+k#;q#’r}eKK#}w’r}eKK{nl]’/#;#q#n’){)#}w’){){nl]’/+#n’;d}rw’ i;# ){n\
l]!/n{n#’; [...]
Filed under: Programming, linux, technical | Leave a Comment »
Posted on November 6, 2006 by awmanoj
I got stuck for last half an hour at ‘getting the values of multiple selected items in a muliple selection box’ using Ruby/Rails. Got it after hard ‘googling’ and got the solution here.
When trying to get multiple selected values from a <SELECT> tag into @params, call your parameter something with [] on the end. [...]
Filed under: Programming, Rails, Ruby, technical | 3 Comments »