473,394 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

C Program to compare two files

I need to write a C program to compare two files not in the same sequence.

ie. Take one line from first file....compare with all lines in second file....If there is no match....put it in a third file

If there is any match ...leave that line...and go to the second line in the first file....again compare with all lines in second file.

Continue the same procedure till we reach the end of the first file.

kindly let me know if any useful links are there related to this which I can refer to
Apr 14 '07 #1
1 2929
JosAH
11,448 Expert 8TB
I need to write a C program to compare two files not in the same sequence.

ie. Take one line from first file....compare with all lines in second file....If there is no match....put it in a third file

If there is any match ...leave that line...and go to the second line in the first file....again compare with all lines in second file.

Continue the same procedure till we reach the end of the first file.

kindly let me know if any useful links are there related to this which I can refer to
I'd say check out the following functions:
1) fopen
2) fclose
3) fseek
4) fgets
5) fputs
6) strcmp

Sprinkle in two nested loops and voila.

kind regards,

Jos
Apr 14 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

44
by: Xah Lee | last post by:
here's a large exercise that uses what we built before. suppose you have tens of thousands of files in various directories. Some of these files are identical, but you don't know which ones are...
4
by: vinnu | last post by:
Hi All, I am Vineela. Please guide me to write the C code to compare to .LST files which have characters, special characters and numbers. My requirement is : abc (1)df ?(0) ENG 0-...
2
by: Jason Huang | last post by:
Hi, In my Windows Server 2003, I have an user account MyAccount with password MyPassword. I have some c# files in a particular folder MyFolder in that Win2003 machine. Saying I have a short...
0
by: metaperl | last post by:
A Comparison of Python Class Objects and Init Files for Program Configuration ============================================================================= Terrence Brannon bauhaus@metaperl.com...
8
by: Perl Beginner | last post by:
I am new to Perl and new to this site. I have the same question that I keep seeing, but not finding an answer…why doesn’t the compare function work? I’ve been going at this for a while. My code is...
5
by: zr3cool | last post by:
heres the program description.... There exist two text files that are not identical with a size of between 100 and 250 characters. Write a c++ program that will read in these two text files,...
9
by: Keith G Hicks | last post by:
I'm having a lot of trouble with "file in use" errors in my "folder watcher" project. Starting and stopping the watcher and reading my XML file work fine. Once the watcher is started, I'm reading...
10
by: KiSSFRo | last post by:
Hi, I have a program that does the following: given a directory as it's only argument, it goes to that directory and looks for directories inside that contain 2 special types of very large files....
12
by: blackirish | last post by:
Hi all, I am trying to merge 2 XML files that first of all i need to compare nodes of both files according to 2 attributes in the nodes. If those 3 attributes are equal, i need to replace the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.