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
>
>
Find the GNU 'indent' utility. It gives us..
#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;
}
...given your program as input. What do you think?
--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---


|