![]() |
|
#1
|
|||
|
|||
Comparing Text Files (new programmer)Hi there! I'm having a bit of trouble with a program I'm trying to write. What I want to do is have two files entered at the command line and then the program will see if they are the same or not (checking character by character). If they are not the same the program will display the letter number where the two files differ. My problem is I'm having difficulty trying to figure out how to write a loop that will read the two files and then compare them character by character. My thoughts were this:
1. Open both text files 2. Read each file into a string buffer 3. Go through the string buffers and compare them to each other character by character until EOF or a different character is present I know what I want to do but actually writing the code is what is confusing me. Any help would be greatly appriciated. Thanks. |
|
#2
|
||||
|
||||
|
Hello trust.
I think your problem would be better solved by reading the files char by char and comparing them. That way, you don't need to worry about trying to allocate a string buffer and what size it needs to be for the file etc. I would set a forever loop that would break based upon different conditions. Inside that loop do:
Overall, this isn't too terribly difficult of a program. Good luck! d |
|
#3
|
|||
|
|||
|
Thanks dsmith! Your suggestions worked out perfectly.
|
Recent GIDBlog
Python ebook by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| burning problems PLEASE PLEASE HELP | kelticeire | Computer Hardware Forum | 4 | 01-Dec-2006 16:39 |
| CD burner wont burn!! | robertli55 | Computer Hardware Forum | 1 | 18-Jun-2004 11:53 |
| Yet another CD burner problem: Lite-On LSC-24082K | Erwin | Computer Hardware Forum | 1 | 22-May-2004 12:28 |
| opening files and displaying text | pin215 | C++ Forum | 7 | 21-Feb-2004 22:27 |
| Manipulating text Files | k209310 | C++ Forum | 0 | 17-Nov-2003 11:23 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The