On 2 May, 22:40, "Bill Cunningham" <nos...@[EMAIL PROTECTED]
> wrote:
> =A0 =A0 I have looked this program up and down and I don't see what's
wron=
g with
> it. But it always breaks and gives me an error "mode error" no matter
whic=
h
> mode binary or text I choose. This simple program is supposed to take as
> argv[1] a "b" or "t" for binary or text. It's not taking anything.
>
> #include <stdio.h>
>
> int main(int argc, char **argv) {
> =A0char *b;
> =A0int a;
> =A0FILE *ifp,*ofp;
> =A0if (argc!=3D4) {
> =A0fprintf(stderr,"usage error\n");
> =A0return -1;
> =A0}
> =A0if (argv[1]=3D=3D"b") {
> =A0b=3D"rb";
> =A0}
> =A0if (argv[1]=3D=3D"t") {
> =A0b=3D"rt";
> =A0}
> =A0if (argv[1]!=3D"t"||argv[1]!=3D"b") {
> =A0fprintf(stderr,"mode error\n");
> =A0return -1;
> =A0}
> =A0if ((ifp=3Dfopen(argv[2],b))=3D=3D0) {
> =A0fprintf(stderr,"open error i\n");
> =A0return -1;
> =A0}
> =A0if ((ofp=3Dfopen(argv[3],b))=3D=3D0) {
> =A0fprintf(stderr,"open error o\n");
> =A0return -1;
> =A0}
> =A0while(a!=3DEOF)
> =A0a=3Dfgetc(ifp);
> =A0fputc(a,ofp);
> =A0printf("done\n");
> =A0return 0;}
>
> =A0 =A0 Is anyone good enough to glance at this and see what's wrong?
your space key is broken.
You can't be bothered to indent your code.
I can't be bothered to read your unindented code.
--
Nick Keighley


|