can you clarify more please. also I have anothe question ?? what is the way to declare a two dimensional matrix in c is it like that A[N,M] or A[N][M] which is one is the right form
--- On Tue, 8/12/09, Rafae Ashfaq <[email protected]> wrote: From: Rafae Ashfaq <[email protected]> Subject: Re: [c-prog] Re: samar To: [email protected] Date: Tuesday, 8 December, 2009, 10:52 AM simple...!!! !!!!!!! initialize them as array elements and then in tke other function display them using "cout". --- On Tue, 12/8/09, samar aseeri <samaraseeri@ yahoo.com> wrote: From: samar aseeri <samaraseeri@ yahoo.com> Subject: Re: [c-prog] Re: samar To: c-p...@yahoogroups. com Date: Tuesday, December 8, 2009, 4:04 AM what I want is if the first file has the following data 1 2 3 4 5 6 7 8 9 I want the following data to be copied to the other program 2 4 6 8 i.e copy the even lines --- On Tue, 8/12/09, Peter Nilsson <peternilsson42@ yahoo.com> wrote: From: Peter Nilsson <peternilsson42@ yahoo.com> Subject: [c-prog] Re: samar To: c-p...@yahoogroups. com Date: Tuesday, 8 December, 2009, 4:29 AM samar aseeri <samaraseeri@ ...> wrote: Subject: samar Please make your subject line describe the nature of your post. Your name is far from a good description of the content. > 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. Before you change the code, you first have to decide what part you want to return. Is it a number of characters, a a number of words, a numbr of lines, only every third palindrome, ... what? > #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*/ These messages are better off directed to stderr. > 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*/ That's your core loop. What you need is... while (...keep going condition... && (c = fgetc(inFilePtr) ) !=EOF) > { > 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*/ ITYM could, not coulk. > } /*end else*/ > return 0; /*indicates successful termination* / Which would be an ironic thing to return if it couldn't open either stream. > }/*end main*/ -- Peter 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] [Non-text portions of this message have been removed] 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]
