Hello All,
Definite newbie here! I want this code to read a file and take each line that does not begin with "." and put it in another text file. It appears the "if" statement is only ran once. I wonder if I am missing dealing with the new line character. Any help would be great :)
Sample input file:
.
D41D8CD98F00B204E9800998ECF8427E .
./.DS_Store
194577A7E20BDCC7AFBB718F502C134C ./.DS_Store
./check.txt
5E8F1ED0F0F32C52DA0C7B682E159C46 ./check.txt
./CheckDuplications.sh
BE7AEE039D106ED86FE06B6A0C2C6CDC ./CheckDuplications.sh
./ChecksumErrorts.txt
D41D8CD98F00B204E9800998ECF8427E ./ChecksumErrorts.txt
./ChecksumOutput.txt
2001C2250DBA22E6BFF2271448C83E15 ./ChecksumOutput.txt
./dups.txt
D41D8CD98F00B204E9800998ECF8427E ./dups.txt
./test copy 2.sh
997A4E239A6DF944A34BC840E7E02B4E ./test copy 2.sh
./test copy.sh
997A4E239A6DF944A34BC840E7E02B4E ./test copy.sh
./test.sh
997A4E239A6DF944A34BC840E7E02B4E ./test.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
#include <fstream>
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
int main(){
string string1;
string string2 = ".";
string string3;
string string4;
ifstream fileIn;
ifstream fileIn2;
ofstream fileOut;
fileIn.open("Check.txt");
if ( ! fileIn ) {
cout << "Error: Can't open the file named Check.txt.\n";
}
getline( fileIn, string1);
while( true) {
getline( fileIn, string3);
cout << "\nThis is string3: " << string3;
string4 = string3.substr( 0, 1 );
cout << "\nstring4 " << string4;
if ( string4.compare(string2) != 0){
fileOut.open("test.txt");
fileOut << string3;
string3.clear();
string4.clear();
}
if ( fileIn.eof()) {
break;
|
}
}
return 0;
}