954,480 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Adding datas of two files in C

Hello
I am having 3 files.
a file contains text as aaaa,bbbb,cccc
b file contains text as 1111,2222,3333
so i want to read these 2 files and write to new file as aaaa1111,bbbb2222,cccc3333.
Can i able to do this?

bharanidharanit
Junior Poster
145 posts since Nov 2008
Reputation Points: 8
Solved Threads: 3
 

open first input file A
open output file
read input file A (probably use fgets() )
write to output file (using fprintf() or fputs() )
close input file A
open input file B
repeat the above for B
close both files and you are done :)

You need to study your textbook about the functions fopen(), fgets(), fprintf(), fputs(), and fclose(). You also need to know about character arrays that hold the information in memory that the fgets() function uses.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You