Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > Re: program bug
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 36 of 36 Topic 26044 of 26972
Post > Topic >>

Re: program bug

by Nick Keighley <nick_keighley_nospam@[EMAIL PROTECTED] > May 6, 2008 at 02:28 AM

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
 




 36 Posts in Topic:
program bug
"Bill Cunningham&quo  2008-05-02 21:40:19 
Re: program bug
"Bill Cunningham&quo  2008-05-02 21:53:34 
Re: program bug
Robert Gamble <rgamble  2008-05-02 15:08:03 
Re: program bug
Robert Gamble <rgamble  2008-05-02 15:05:58 
Re: program bug
"Bill Cunningham&quo  2008-05-02 22:16:27 
Re: program bug
CBFalconer <cbfalconer  2008-05-02 18:47:28 
Re: program bug
"Bill Cunningham&quo  2008-05-02 22:21:04 
Re: program bug
Robert Gamble <rgamble  2008-05-02 15:28:04 
Re: program bug
"Bill Cunningham&quo  2008-05-03 20:42:30 
Re: program bug
Keith Thompson <kst-u@  2008-05-03 14:48:48 
Re: program bug
"Bill Cunningham&quo  2008-05-03 22:58:24 
Re: program bug
Keith Thompson <kst-u@  2008-05-03 18:08:44 
Re: program bug
"Default User"   2008-05-04 03:20:33 
Re: program bug
Keith Thompson <kst-u@  2008-05-03 21:17:13 
Re: program bug
"Default User"   2008-05-04 19:03:07 
Re: program bug
vippstar@[EMAIL PROTECTED  2008-05-03 16:21:48 
Re: program bug
CBFalconer <cbfalconer  2008-05-03 20:29:01 
Re: program bug
Joe Wright <joewwright  2008-05-02 18:25:33 
Re: program bug
Ian Collins <ian-news@  2008-05-03 10:28:17 
Re: program bug
"Bill Cunningham&quo  2008-05-02 22:36:04 
Re: program bug
Robert Gamble <rgamble  2008-05-02 15:36:31 
Re: program bug
Ian Collins <ian-news@  2008-05-03 11:31:53 
Re: program bug
Joe Wright <joewwright  2008-05-02 20:18:17 
Re: program bug
Ian Collins <ian-news@  2008-05-03 12:31:09 
Re: program bug
"Bill Cunningham&quo  2008-05-02 23:15:17 
Re: program bug
Keith Thompson <kst-u@  2008-05-02 23:56:46 
Re: program bug
Richard Heathfield <rj  2008-05-03 07:04:24 
Re: program bug
CBFalconer <cbfalconer  2008-05-02 18:50:15 
Re: program bug
user923005 <dcorbit@[E  2008-05-02 21:25:53 
Re: program bug
"Bill Cunningham&quo  2008-05-03 15:52:27 
Re: program bug
vippstar@[EMAIL PROTECTED  2008-05-03 09:01:52 
Re: program bug
Eligiusz Narutowicz<el  2008-05-04 08:41:56 
Re: program bug
"Bill Cunningham&quo  2008-05-04 21:25:27 
Re: program bug
Barry Schwarz <schwarz  2008-05-04 15:20:34 
Re: program bug
"Bill Cunningham&quo  2008-05-06 02:30:36 
Re: program bug
Nick Keighley <nick_ke  2008-05-06 02:28:14 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 16:02:22 CDT 2008.