yah it works you just have to fill some data in a file then afer you compile you write ./arg s ss that is if arg is the executable and s is the filled file and ss is the file I want to copy to. after that when you open ss you'll find the same data you filled in s
--- On Mon, 7/12/09, Tyler Littlefield <[email protected]> wrote: From: Tyler Littlefield <[email protected]> Subject: Re: [c-prog] samar To: [email protected] Date: Monday, 7 December, 2009, 7:50 AM does this actually work? it looks like your file pointers are being assigned to NULL in the if statements. On Dec 6, 2009, at 3:40 PM, samar aseeri wrote: > hi, > > the below attached program uses the argument command line the copy a file to > another file. my question is what can I change in the program to make only > part of the first file be copied to the second. > > #include<stdio.h> > int main(int argc, char *argv[]) > { > FILE *inFilePtr; /*input file pointer*/ > FILE *outFilePtr; /*output fole pointer*/ > int c,i; > /*check number of command-line arguments */ > if(argc != 3){ > printf("Usage: mycopy infile outfile\n");} /*end if*/ > else /*if input file can be opened*/ > { > if((inFilePtr=fopen(argv[1],"r"))!=NULL) /*if input file can be >opened*/ > { if((outFilePtr =fopen(argv[2], "w")) != NULL) /*if output file can >be opened*/ > {while((c = fgetc(inFilePtr)) !=EOF) /*read and output >characters*/ > { > fputc(c,outFilePtr);}/*end while*/ > }/*end if*/ > else /*output file could not be opened*/ > {printf("File\"%s\" could not be opened\n", argv[2]); > } /*end else*/ > }/*end if*/ > else /*input file could not be opened*/ > { printf("File\"%s\" coulk not be opened\n", argv[1]);} /*end else*/ > } /*end else*/ > return 0; /*indicates successful termination*/ > }/*end main*/ > > Get your preferred Email name! > Now you can @ymail.com and @rocketmail.com. > http://mail.promotions.yahoo.com/newdomains/aa/ > > [Non-text portions of this message have been removed] > > [Non-text portions of this message have been removed] ------------------------------------ To unsubscribe, send a blank message to <mailto:[email protected]>.Yahoo! Groups Links New Email addresses available on Yahoo! Get the Email name you've always wanted on the new @ymail and @rocketmail. Hurry before someone else does! http://mail.promotions.yahoo.com/newdomains/aa/ [Non-text portions of this message have been removed]
