Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <unistd.h>
- #include <errno.h>
- #include <limits.h>
- #include <string.h>
- #include <fcntl.h>
- #include <stdlib.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #define SECTOR_SIZE 4096
- char numeFisierSursa[PATH_MAX],numeFisierDestinatie[PATH_MAX];
- char buffer[SECTOR_SIZE],comanda[10];
- int bytes_read;
- int main(int argc,char **argv)
- {
- FILE *fptr1,*fptr2;
- printf("Nume fisier sursa : ");
- scanf("%s",numeFisierSursa);
- printf("Nume fisier destinatie : ");
- scanf("%s",numeFisierDestinatie);
- if((fptr1 = fopen(numeFisierSursa,"r")) == NULL)
- {
- perror("Error on opening file");
- exit(1);
- }
- if(fopen(numeFisierDestinatie,"w")!=NULL)
- {
- printf("Doriti sa suprascrieti continutul ? da/nu ");
- scanf("%10s",&comanda);
- if(strcmp(comanda,"da")!=0)
- {
- printf("\nNu ati acordat permisiunea");
- exit(5);
- }
- fptr2 = fopen(numeFisierDestinatie,"wb");
- chmod(numeFisierDestinatie,S_IRUSR | S_IWUSR);
- }
- while(fgets(buffer,SECTOR_SIZE,fptr1)!=NULL)
- {
- for(int i=0;buffer[i]!=NULL;i++)
- if(buffer[i] >= 'a' && buffer[i] <= 'z')
- buffer[i]=buffer[i]-'a'+'A';
- fprintf(fptr2,"%s",buffer);
- }
- if(fclose(fptr1)==-1||fclose(fptr2)==-1)
- {
- perror("Error on closing file");
- exit(4);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement