Advertisement
Guest User

setCV

a guest
Mar 30th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <errno.h>
  4. #include <limits.h>
  5. #include <string.h>
  6. #include <fcntl.h>
  7. #include <stdlib.h>
  8. #include <sys/types.h>
  9. #include <sys/stat.h>
  10.  
  11. #define SECTOR_SIZE 4096
  12.  
  13. char numeFisierSursa[PATH_MAX],numeFisierDestinatie[PATH_MAX];
  14. char buffer[SECTOR_SIZE],comanda[10];
  15. int bytes_read;
  16.  
  17. int main(int argc,char **argv)
  18. {
  19. FILE *fptr1,*fptr2;
  20.  
  21. printf("Nume fisier sursa : ");
  22. scanf("%s",numeFisierSursa);
  23.  
  24. printf("Nume fisier destinatie : ");
  25. scanf("%s",numeFisierDestinatie);
  26.  
  27. if((fptr1 = fopen(numeFisierSursa,"r")) == NULL)
  28. {
  29. perror("Error on opening file");
  30. exit(1);
  31. }
  32.  
  33. if(fopen(numeFisierDestinatie,"w")!=NULL)
  34. {
  35. printf("Doriti sa suprascrieti continutul ? da/nu ");
  36. scanf("%10s",&comanda);
  37. if(strcmp(comanda,"da")!=0)
  38. {
  39. printf("\nNu ati acordat permisiunea");
  40. exit(5);
  41. }
  42. fptr2 = fopen(numeFisierDestinatie,"wb");
  43. chmod(numeFisierDestinatie,S_IRUSR | S_IWUSR);
  44. }
  45. while(fgets(buffer,SECTOR_SIZE,fptr1)!=NULL)
  46. {
  47. for(int i=0;buffer[i]!=NULL;i++)
  48. if(buffer[i] >= 'a' && buffer[i] <= 'z')
  49. buffer[i]=buffer[i]-'a'+'A';
  50.  
  51. fprintf(fptr2,"%s",buffer);
  52. }
  53.  
  54. if(fclose(fptr1)==-1||fclose(fptr2)==-1)
  55. {
  56. perror("Error on closing file");
  57. exit(4);
  58. }
  59.  
  60. return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement