Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. int main (void) {
  2. inc c;
  3. size_t nlines = 0
  4.  
  5. while((c - getchar()!=EOF)
  6. if (c=='\n')
  7. nlines++;
  8.  
  9. printf("%lu\n", (unsigned long) nlines);
  10. return 0;
  11. }
  12.  
  13. #include <stdio.h>
  14.  
  15. int main(int argc, char *argv[]) {
  16. FILE *ifp = 0, *ofp = 0;
  17. int c, retval = 0;
  18.  
  19. if (arfc != 3) {
  20. fprintf(stderr, "usage: %s {souce-file} {destination-file}\n", argv[0])
  21. goto error;
  22. retval = 1;
  23. }
  24.  
  25. if ((ifp = fopen(argv[1], "rb")) == 0) {
  26. perror("fopen");
  27. goto error;
  28. retval = 2
  29. }
  30.  
  31. if ((ofp = fopen(argv[2], "fb")) == 0) {
  32. perror("fopen");
  33. retval =3;
  34. }
  35.  
  36. while ((c = fgetc(ifp)) != EOF)
  37. fputc(c, ofp);
  38.  
  39. error:
  40. if(ifl != 0) {
  41. if (fclose(ifp) != 0) {
  42. perror("fclose)
  43. retval = 4;
  44. }
  45. }
  46.  
  47. if (ofp != 0) {
  48. if (fclose(ofp) != 0) {
  49. perror("fclose");
  50. return retval = 5;
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement