Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <unistd.h>
- #include <fcntl.h>
- #include <stdio.h>
- #include <stdlib.h>
- int main(int argc, char* argv[]){
- int des;
- int des2;
- int i;
- int a = 0;
- if (argc == 2) {
- char buf[0x100];
- snprintf(buf, sizeof(buf), "%s", argv[1]);
- des = open(buf, O_RDONLY, 0666);
- des2 = open("translated.txt", O_WRONLY, 0666);
- if(des < 0 || des2 < 0){
- write( 2, "Error!\n", 7 );
- return 1;
- }
- } else {
- printf ("Nieprawidlowa liczba argumentow!\n");
- }
- char tst[100];
- char tst2[100];
- read(des, tst, sizeof(tst));
- for (i=0;i<100;i++){
- if ((int)tst[i] > 0) {
- tst2[i-a] = tst[i];
- }
- if ((int)tst[i] < 0) {
- if ((int)tst[i] == -123) {
- a++;
- tst2[i-a] = 'a';
- }
- if ((int)tst[i] == -121) {
- a++;
- tst2[i-a] = 'c';
- }
- if ((int)tst[i] == -103) {
- a++;
- tst2[i-a] = 'e';
- }
- if ((int)tst[i] == -126) {
- a++;
- tst2[i-a] = 'l';
- }
- if ((int)tst[i] == -124) {
- a++;
- tst2[i-a] = 'n';
- }
- if ((int)tst[i] == -77) {
- a++;
- tst2[i-a] = 'o';
- }
- if ((int)tst[i] == -101) {
- a++;
- tst2[i-a] = 's';
- }
- if ((int)tst[i] == -68) {
- a++;
- tst2[i-a] = 'z';
- }
- if ((int)tst[i] == -70) {
- a++;
- tst2[i-a] = 'z';
- }
- }
- }
- write(des2, tst2, sizeof(tst));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement