"cr88192" <cr88192@[EMAIL PROTECTED]
> ha scritto nel messaggio
news:876ae$4823f988$ca83b482$8265@[EMAIL PROTECTED]
>
> "rio" <a@[EMAIL PROTECTED]
> wrote in message
> news:4822d8eb$0$41661$4fafbaef@[EMAIL PROTECTED]
>>
>> "Joe Wright" <joewwright@[EMAIL PROTECTED]
> ha scritto nel messaggio
>> news:xdKdnd0Wq_nixb_VnZ2dnUVZ_jSdnZ2d@[EMAIL PROTECTED]
>>> Bill Cunningham wrote:
>>>> I have had several complaints by some people who wish to help me
>>>> and
>>>> I wish to get the problem straight. I wrote this small utility myself
>>>> and
>>>> added some indentation and I wonder if it is acceptable. It does make
>>>> source easier to read.
>>>>
>>>> #include <stdio.h>
>>>> #include <stdlib.h>
>>>>
>>>> int main(int argc, char **argv) {
>>>> if (argc!=3) {
>>>> fprintf(stderr,"usage error\n");
>>>> return -1;
>>>> }
>>>> double x,y;
>>>> x=strtod(argv[1],NULL);
>>>> y=strtod(argv[2],NULL);
>>>> printf("%.2f\n",y/x);
>>>> return 0;
>>>> }
>>>>
>>>> Is this a good example of a properly indended program?
>>
>>>> Bill
>>
>> i like below
>>
>> #include <stdio.h>
>> #include <stdlib.h>
>>
>> int main(int argc, char **argv)
>> {double x, y;
>>
>> if (argc!=3) { fprintf(stderr,"usage error\n"); return -1;}
>>
>> x=strtod(argv[1], 0);
>> y=strtod(argv[2], 0);
>>
>> return (x!=0.0) ?
>> (printf("%.2f\n", y/x), 0): (printf("Error: x==0\n"), -1)
;
>> }
>>
>>
>
> ICK...
>
> these are not exactly the way I would personally use the trinary and
comma
> operators...
>
>
>
> of course, I do have something vaguely similar, but it is more of a
> "compact" style:
>
> #include <stdio.h>
> #include <stdlib.h>
>
> int main(int argc, char **argv) {
> double x, y;
> if (argc!=3) { fprintf(stderr,"usage error\n"); return(-1); }
> x=strtod(argv[1], 0); y=strtod(argv[2], 0);
> if(x==0.0) { printf("Error: x==0\n"); return(-1); }
> printf("%.2f\n", y/x), 0); return(0); }
that your way is not ok i see because you
forget { for if


|