1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
aalyn [17]
3 years ago
9

a. For a file whose size (in terms of number of bytes) is less than or equal to 12, then duplicate the contents of the file so t

hat its total size would be twice as many as its original size.
Mathematics
1 answer:
pickupchik [31]3 years ago
4 0

Answer:

#include <stdio.h>

int main()

{

int check;

char* dirname = "Subdir1";

check = mkdir(dirname,0766);

// check if directory is created or not

if (!check)

{

printf("Subdir1 Directory created\n");

 

char *dirname1="/Subdir1/D1";

if(mkdir("/Subdir1/D1", 0777)==-1)

{

printf("D1 Directory created\n");

int A1 = open ("/Subdir1/D1/A1.txt", 0666);

write(A1, "abcdefghij\n", strlen("abcdefghij\n"));

close(A1);

 

int A2 = open ("/Subdir1/D1/A2.txt", 0666);

write(A2, "you are beautiful\n", strlen("you are beautiful\n"));

close(A2);

 

int A3 = open ("/Subdir1/D1/A3.txt", 0666);

write(A3, "this is terrible!\n", strlen("this is terrible!\n"));

close(A3);

}

else

{

printf("Unable to create directory D1\n");

exit(1);

}

if(mkdir("/Subdir1/D2", 0777)==-1)

{

printf("D2 Directory created\n");

int B1 = open ("/Subdir1/D2/B1.ccc", 0664);

write(B1, "abcdefghij\n", strlen("abcdefghij\n"));

close(B1);

 

int B2 = open ("/Subdir1/D2/B2.ccc", 0664);

write(B2, "you are beautiful\n", strlen("you are beautiful\n"));

close(B2);

 

int B3 = open ("/Subdir1/D2/B3.ccc", 0664);

write(B3, "this is terrible!\n", strlen("this is terrible!\n"));

close(B3);

}

else

{

printf("Unable to create directory D2\n");

exit(1);

}

 

if(mkdir("/Subdir1/D3", 0777)==-1)

{

printf("D3 Directory created\n");

int C1 = open ("/Subdir1/D3/C1.txt", 0644);

write(C1, "abcdefghij\n", strlen("abcdefghij\n"));

close(C1);

 

int C2 = open ("/Subdir1/D3/C2.ddd", 0644);

write(C2, "you are beautiful\n", strlen("you are beautiful\n"));

close(C2);

 

int C3 = open ("/Subdir1/D3/C3.txt", 0644);

write(C3, "this is terrible!\n", strlen("this is terrible!\n"));

close(C3);

}

else

{

printf("Unable to create directory D2\n");

exit(1);

}

 

}

 

 

else {

printf("Unable to create directory Subdir1\n");

exit(1);

}

return 0;

}

Program 2:

#include <stdio.h>

 

long int findSize(char file_name[])

{

// opening the file in read mode

FILE* fp = fopen(file_name, "r");

 

// checking if the file exist or not

if (fp == NULL) {

printf("File Not Found!\n");

return -1;

}

 

fseek(fp, 0L, SEEK_END);

 

// calculating the size of the file

long int res = ftell(fp);

 

// closing the file

fclose(fp);

 

return res;

}

 

// Driver code

int main()

{

FILE *fptr1;

char c;

char file_name[] = {"D1.txt"};

long int res = findSize(file_name);

if (res != -1)

{

printf("Size of the file is %ld bytes \n", res);

if(res<=12)

{

fptr1 = fopen("D1.txt", "r");

c = fgetc(fptr1);

while (c != EOF)

{

fputc(c, fptr1);

c = fgetc(fptr1);

printf(c);

}

}

}

return 0;

}

You might be interested in
The number of fish (f) in a fish tank increases when the number of algae blooms (a) decreases. Write the correct equation for th
Travka [436]
The problem ask to give the correct equation for this scenario that is given in your problem and solve for the number of fish when there are 4 algae blooms. Base on that fact, the best answer would be letters A. f=1a; f=4 and C. f=100 over a; f=25. I hope you are satisfied with my answer .
8 0
3 years ago
Read 2 more answers
One bow requires 3.2 inches of ribbon. How many<br> bows can be made from 304 inches of ribbon?
lara31 [8.8K]

Answer:

95

Step-by-step explanation:

304/3.2 = 95

3 0
3 years ago
Read 2 more answers
How do I rotate a parabola from opening up to opening horizontally?
Bogdan [553]
-- take the equation of the parabola

-- wherever you see 'y' in the equation, write 'x'

-- wherever you see 'x' in the equation, write 'y'
8 0
3 years ago
Read 2 more answers
Find the area of the shape
vova2212 [387]

37.68 is the area of the Pac-Man

5 0
3 years ago
Read 2 more answers
How can I solve this word problem or wat do I do to solve this problem
MrMuchimi
Basically, to solve this problem, you have to solve or every single multiple choice.

a)3-7+(-10)=3-7-10=-14
b)3+7-(-10)=3+7+10=20
c)3-7-(-10)=3-7+10=6
d)3+7+(-10)=3+7-10=0

Thus B is the right choice because B is the biggest
6 0
3 years ago
Other questions:
  • amanda arranged 5 baskets of flowers. she finished at 4:10pm it took her 20 mins to arrange each basket of flowers. at what time
    15·1 answer
  • Help with 9 and 10 please
    13·1 answer
  • Which is the quotient for 3.12÷6.5? A 0.0 48B 0.48C 4.8 D 48
    11·1 answer
  • Ben bought a car for $35,000 in 2011. The car
    14·1 answer
  • How many sides does 52 quadrilateral have?
    14·1 answer
  • A number increased by 9 is -4. What is<br> the number? Write an equation and solve.
    10·2 answers
  • What is equivalent to -23-(26)=x
    10·1 answer
  • Ralph is making orange juice.
    15·1 answer
  • Volume of a cylyinder witha heght of 2.3 and a base diameter of 15.2
    7·1 answer
  • Help, please!! Graph the quadratic function.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!