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