Below is C program to File to upper case using command line arguments .
Program:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | /* File to upper case using command line arguments */ #include<stdio.h> int main( int n, char *a[]) { int c; FILE *fr,*fw; if (n!=3) { printf ( "Invalide numbers of arguments." ); return 1; } if ((fr= fopen (a[1], "r" ))==NULL) { printf ( "File can't be open." ); return 1; } if ((fw= fopen (a[2], "r+" ))==NULL) { printf ( "File can't be open." ); fclose (fr); return 1; } while (1) { c= fgetc (fr); if ( feof (fr)) break ; c=~c; fputc (c,fw); } fclose (fr); fclose (fw); return 0; } |
No comments:
Post a Comment