Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Zad 1 :
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #define BUFSIZE 20
- int main(int argc, char **argv)
- {
- if(argc < 3)
- return (-1);
- char bufor[BUFSIZE];
- int n;
- int pierwszy = open(argv[1], O_RDONLY);
- int drugi = open(argv[2], O_WRONLY);
- while((n = read(pierwszy, bufor, BUFSIZE)) > 0)
- {
- write(drugi, bufor, n);
- }
- close(pierwszy);
- close(drugi);
- return 0;
- }
- /// Zad 2 :
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <memory.h>
- int main(int argc, char **argv)
- {
- if(argc < 3)
- return (-1);
- char bufor;
- char text[100][100];
- memset(text, '\0', 100*100);
- int n;
- int pierwszy = open(argv[1], O_RDONLY);
- int drugi = open(argv[2], O_WRONLY);
- int IloscNowychLinni=0;
- {
- while((n = read(pierwszy, &bufor, 1)) > 0)
- {
- if(bufor=='\n'){
- IloscNowychLinni++;
- continue;
- }
- }
- }
- {
- int i=0;
- int j=0;
- lseek(pierwszy,0,SEEK_SET);
- while((n = read(pierwszy, &bufor, 1)) > 0)
- {
- if(bufor=='\n'){
- i=i+1;
- j=0;
- continue;
- }
- j=j+1;
- text[i][j]=bufor;
- }
- }
- {
- int i,j,k;
- for(i=0;i<IloscNowychLinni;i++){
- k=0;
- for(j=0;j<100;j++){
- if(text[i][100-j]=='\0'){
- continue;
- }
- bufor=text[i][100-j];
- write(drugi,&bufor,1);
- }
- bufor='\n';
- write(drugi,&bufor,1);
- }
- }
- close(pierwszy);
- close(drugi);
- return 0;
- }
- // zad 3 :
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <stdio.h>
- #include <memory.h>
- int main(int argc, char **argv)
- {
- if(argc < 2)
- return (-1);
- char bufor;
- int n;
- int pierwszy = open(argv[1], O_RDONLY);
- int max=0;
- int temp=0;
- while((n = read(pierwszy, &bufor, 1)) > 0)
- {
- if(bufor=='\n'){
- if(temp>max)
- {
- max=temp;
- }
- temp=0;
- }
- temp++;
- }
- close(pierwszy);
- printf("Najwieksza liczba liter w zdaniu to : %d \n", max);
- return 0;
- }
- /// zad 4:
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <stdio.h>
- #include <memory.h>
- int main(int argc, char **argv)
- {
- int RozmiarPlikow=0;
- int i;
- int n;
- int bufor;
- for(i=1;i<argc;i++){
- int plik = open(argv[1], O_RDONLY);
- while((n = read(plik, &bufor, 1)) > 0)
- {
- RozmiarPlikow++;
- }
- close(plik);
- }
- printf("Wspolny rozmiar plikow to : %d \n", RozmiarPlikow);
- return 0;
- }
Add Comment
Please, Sign In to add comment