943,733 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 351
  • C RSS
Jun 19th, 2009
0

Adding datas of two files in C

Expand Post »
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?
Similar Threads
Reputation Points: 8
Solved Threads: 3
Junior Poster
bharanidharanit is offline Offline
140 posts
since Nov 2008
Jun 19th, 2009
0

Re: Adding datas of two files in C

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.
Last edited by Ancient Dragon; Jun 19th, 2009 at 12:26 am.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is online now Online
21,950 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Reading Problem in C
Next Thread in C Forum Timeline: recursive palindrome





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC