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:c-prog-unsubscr...@yahoogroups.com>.Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/c-prog/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/c-prog/join
    (Yahoo! ID required)

<*> To change settings via email:
    c-prog-dig...@yahoogroups.com 
    c-prog-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    c-prog-unsubscr...@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply via email to