View Single Post
  #1 (permalink)  
Old 08-03-2007, 01:19 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
PT Admin
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,118
iTrader: (0)
HelloWorld is a jewel in the roughHelloWorld is a jewel in the roughHelloWorld is a jewel in the rough
Icon13 How to read file in C++?

here's the code that I have for now:

PHP Code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
ifstream infileinfile2;
infile.open("pdf1.txt");
infile2.open("pdf2.txt");
if (!
infile) {
cout << "Error in reading pdf1.txt" << endl;
exit(
1);
}
if (!
infile2) {
cout << "Error in reading pdf2.txt" << endl;
exit(
1);
}
string r infile.read();
string r2 infile2.read();
while (
infile.read() != null) {
if (
!= r2) {
cout << "Different at " << << endl;
}
infile.read();
}
return 
0;

I want it to read it line by line, but also have the ability to tokenize (in java lol..) something, please help me where should I look for this information and suggestion to what do I need to do to read a file and compare it to other file.

I want to compare one file with the other to see if they're the same because there's going to be a server backup at my workplace, so we have to make sure if we still have the same data from the previous server.

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote