Click here to Skip to main content
15,850,750 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello there,
I have two different file.

File1.txt
Name       Gender   Status

Messi       male    single

Ronaldo     male     single 

Speed      unknown  unknown 

File2.txt
Name      condition

Messi      1

Ronaldo    1

Speed      10

But now I to input these file by the user then I want to show it in my program in this following formet
Name       Gender   Status    condition

Messi       male    single     1

Ronaldo     male     single    1

Speed      unknown  unknown    10

Notice that, we have the condition data inserted.

How to do this in c programming

I tried to merge two txt file in another txt file but it is not working. Beside of that I have no idea how to do that.

What I have tried:

I tried to merge two txt file into another txt file but it is making a mess instead of giving me the following format.
Posted
Updated 20-Nov-22 13:52pm
v2
Comments
Graeme_Grant 20-Nov-22 18:45pm    
We can't see your screen & code from here. We are also not here to do your work for you. If you want help, then you need to post code and explain where you are having issues, error messages encountered, etc...

1 solution

Here is how I would approach it:
1. Define a class with the properties: Name, Gender, Status, Condition
2. Define a list/array to hold a collection of the class
3. Open first file and load the list
4. Open second file and update the list
5. Write the list in a new file.

ref: C - File I/O (read/write) - TutorialPoint[^]
ref: C - Arrays - TutorialPoint[^]
ref: C++ Classes and Objects - W3 Schools[^]
 
Share this answer
 
v3
Comments
Pococurante Bird 20-Nov-22 19:00pm    
Thank you so much!
Pococurante Bird 20-Nov-22 19:02pm    
Also I am curious, when you are talking about update? what would happen to the other boxes like gender and status? would they still stay? if they are then could you please help me to understand how>
Pococurante Bird 20-Nov-22 19:05pm    
last one, when I am calling the second file, do I have to use the same FILE pointer ?
for example I used FILE *update for inserting the first text data. To update with second file data do I have to use *update again?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900