Question

I try to link two different directories, file together to one file. After I finish, here...

I try to link two different directories, file together to one file.

After I finish, here appear one question.
First open the file, it show source in file1
Second open the file, it shows source in file2
Third is file1
Fourth is file2

Here is the explanation, but I still confuse how to solve it.

Someone can explain more detail and how can I solve this problems?

You are not keeping track of the changes, there is an offset that indicates the position in memory where the writing is taking place, from what you describe it seems that you are always using the same offset position (the start of the memory block) so it overwrites every time.

Homework Answers

Answer #1

You want to merge the contents of two different files as per my assumption. I'll give the logical algorithm for the solution of this problem.

Step 1:

we have to read the contents from file1

Step 2:

then we have write the contents of file1 into another new file which we can name as file3. Note that we are writing content in the new file.

Step 3:

Read the contents from file2. Read the contents from file two in the same way you read from the previous file i.e. file1

Step 4:

Now you have to append the content of file2 into file3. Try to append content in the file not write because both operations are different in terms of functionality. The Write operation empty the file first and then write the content in it. But the append operation write the content at the ending of the file means it append the content after the last charecter of the file.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
How would I solve these python problems? A) File Display Download the file from here named...
How would I solve these python problems? A) File Display Download the file from here named numbers.txt . Write a program that displays all of the numbers in the file. numbers.txt contains 22 14 -99 AB B) Error Check Float Input When you want an int input you can check the input using the string isdigit() method. However, there is no comparable check for float. Write a program that asks the user to enter a float and uses a try-except...
You must write a function that works like a small editor. It should open an existing...
You must write a function that works like a small editor. It should open an existing file (let us say this is File1.txt. This file must exist before the function is run), read it line by line. Then write it to another file (let us say this is File2.txt. This file need not exist since Python will create it). However, if a certain line exists in the first file, it should be replaced by another line supplied by you. You...
Sunshine Enterprises Case Study “I think the waiter wrote in an extra $25 tip on my...
Sunshine Enterprises Case Study “I think the waiter wrote in an extra $25 tip on my Sunshine Café bill after I received and signed my credit card receipt,” Mr. Mark Otter said to the restaurant manager, Brad Gladiolus. “Mr. Otter, mail me a copy of the restaurant receipt and I’ll investigate,” responded Mr. Gladiolus. “I don’t have the receipt—I lost it—but I have my monthly credit card statement,” replied Mr. Otter. Mr. Gladiolus hesitated, then said, “Mr. Otter, I don’t...
There are two reflective essays from MED students during their third year internal medicine clerkship. One...
There are two reflective essays from MED students during their third year internal medicine clerkship. One student sees each connection to a patient as like the individual brush strokes of an artist and the other sees gratitude in a patient with an incurable illness and is moved to gratitude in her own life. (WORD COUNT 500) Reflect on both essays and then choose one and describe how the student grew from the experience. Then explain what you learned as a...
read Seasons of Love chapter:measuring a child's life after suicide. please answer the questions : reflect...
read Seasons of Love chapter:measuring a child's life after suicide. please answer the questions : reflect on what happens to the families when there is a suicide in the family, based on the Seasons of Love chapter...how should people be told? What details are best left unshared? below is the story These theories may have a certain face-validity, but they often neglect environmental or contextual factors that are innate to answering the question of “why” a person might engage in...
The Business Case for Agility “The battle is not always to the strongest, nor the race...
The Business Case for Agility “The battle is not always to the strongest, nor the race to the swiftest, but that’s the way to bet ’em!”  —C. Morgan Cofer In This Chapter This chapter discusses the business case for Agility, presenting six benefits for teams and the enterprise. It also describes a financial model that shows why incremental development works. Takeaways Agility is not just about the team. There are product-management, project-management, and technical issues beyond the team’s control. Lean-Agile provides...
QUESTION 1 1. Brianna is trying to increase her chances of being promoted to vice president...
QUESTION 1 1. Brianna is trying to increase her chances of being promoted to vice president by working to build good work relationships with other managers outside her own department. Brianna's behavior should be viewed as dysfunctional politics. functional politics. coercive power. functional influence. 2 points QUESTION 2 1. The Gingerbread Factory has a separate unit that makes their chocolate crunch cookies and another unit that is completely responsible for all operations in producing their ginger snap cookies. The Gingerbread...