Trying to compare the contents of 2 files, and if they match return(0); and exit, but if they dont match to then run emailme.exe which runs a keyboard/mouse macro written using jitbit macro recorder to e-mail me that an automated task failed to complete.
The automated task is a batch file and at the end of the batch file I have:
echo. %date%>Last_Run.txt
When testing this program I am getting:
String Data Read in from files shown below:
03/21/2013
ê$>
Press any key to continue . . .
where I would expect to see:
String Data Read in from files shown below:
Thu 03/21/2013
Thu 03/21/2013
Press any key to continue . . .
since both text files ( Last_Run.txt and Todays_Date.txt ) contain Thu 03/21/2013
char string1[20];
char string2[20];
// Write todays date to file for comparison with same format of that of batch log
system("@echo. %date%>Todays_Date.txt");
if (!infile2) {
cout << "There was a problem opening file "
<< inname2
<< " for reading."
<< endl;
return 0;
}
while (infile >> string2) {
}
//NOTE: Display string data - remove from program when correct
cout<<"String Data Read in from files shown below: \n";
cout<<"\n"<<string1<<"\n"<<string2<<"\n";
system("pause");
//NOTE: Remove everything between here and above note once correct
Haven't performed a string compare in years, so had to reference online how to do it, and now I am stumped as to why reading in from these files the string data being passed to the char variables is messing up, and causing string compare to malfunction due to data read in not matching.
@OP What are you trying to do ? Writing current date to a file using system and shell %date% environment, reading it back and comparing it with other file contents it not a logical thing to do.