/* * bugEyed 10-18-99 * This will run through a text file and take out all of the IP's it can find. * I know that there are some problems with it, but it works for the purposes * I need it for. The problems I know of are: * sometimes you might see an IP like 14202.234.10.1 * - this problem results when before the actual IP you have something like * domain214.com has address 202.234.10.1 * I'm working on how to fix this, but for now it is easy to spot out of * of the output file and you can just delete the uneeded numbers * - The other problem is the array size: It is only big enough to hold 15 * characters. But when something like above occurs then you get * an overflow. Just change the array to something bigger or find the * line that is causing the problem and make it shorter. * * If you find any more problems just give me an email letting me know * what it is. You can email me at bbugeyed@hotmail.com * / #include #include int main ( int argc, char* argv[] ) { ifstream inFile; ofstream outFile; char oldInput = '\n'; char address[15], input, dummy; int location = 0; // check to see if in correct format if ( argc != 3 ) { cout << "Usage: " << argv[0] << " 'input file' 'output file'\n"; return 1; } inFile.open(argv[1]); outFile.open(argv[2]); if ( !inFile || !outFile ) { cout << "Can not open file\n"; return 1; } for ( int x = 0; x < 15; x++ ) address[x] = 't'; // 46. 48-57 while ( inFile ) { inFile.get(input); if ( input == 46 || oldInput == ' ' || input >= 48 && input <= 57 && oldInput >= 48 && oldInput <= 57 || oldInput == 46) { inFile.get(dummy); if ( dummy == 46 || dummy >= 48 && dummy <= 57 || dummy == '\n') { address[location] = input; location++; inFile.putback(dummy); // put it back on i/o stream } } if ( input == '\n' && oldInput != '\n') { int y = 0; while ( address[y] != 't' ) { outFile << address[y]; y++; } outFile << endl; location = 0; for ( y = 0; y < 15; y++ ) address[y] = 't'; } oldInput = input; } return 0; }