That is a self-defeating argument. This notion of "more compact" boils down to the specifics of subjective style. As such, it is a matter of you finding it more compact for your style. So be it.Originally Posted by Babkockdood
That is a self-defeating argument. This notion of "more compact" boils down to the specifics of subjective style. As such, it is a matter of you finding it more compact for your style. So be it.Originally Posted by Babkockdood
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
This will work
even this will workCode:if (!argv[1]) {printf("There are no arguments.\n"); return 1;} else {printf("There is at least one argument.\n"); return 0;}
if you print whole program in one line it will work depending upon the compiler you are using.Code:if (!argv[1]) {printf("There are no arguments.\n"); return 1;} else {printf("There is at least one argument.\n"); return 0;}
Last edited by Dr.Xperience; 09-19-2010 at 01:00 AM.
...Which is the same as:
And the more you do it, the less pretty it becomes. So eventually you have to put it on multiple rows.Code:switch (y) { case 1: printf("There are no arguments.\n"); return 1; break; case 2: printf("There is at least one argument.\n"); return 0; break; }
yup
I will use switch case when i have to compare single value with multiple value. For comparing one value or to compare multiple values with multiple values i will use if else. Though both have same use.