Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main (void) {
- inc c;
- size_t nlines = 0
- while((c - getchar()!=EOF)
- if (c=='\n')
- nlines++;
- printf("%lu\n", (unsigned long) nlines);
- return 0;
- }
- #include <stdio.h>
- int main(int argc, char *argv[]) {
- FILE *ifp = 0, *ofp = 0;
- int c, retval = 0;
- if (arfc != 3) {
- fprintf(stderr, "usage: %s {souce-file} {destination-file}\n", argv[0])
- goto error;
- retval = 1;
- }
- if ((ifp = fopen(argv[1], "rb")) == 0) {
- perror("fopen");
- goto error;
- retval = 2
- }
- if ((ofp = fopen(argv[2], "fb")) == 0) {
- perror("fopen");
- retval =3;
- }
- while ((c = fgetc(ifp)) != EOF)
- fputc(c, ofp);
- error:
- if(ifl != 0) {
- if (fclose(ifp) != 0) {
- perror("fclose)
- retval = 4;
- }
- }
- if (ofp != 0) {
- if (fclose(ofp) != 0) {
- perror("fclose");
- return retval = 5;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement