"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) ;
}


|