One of my files should be different than the others and this program is supposed to tell me which. I have a feeling that the "_setmode..." could be wrong (actually almost sure, it doesn't seem to have any effect - it's supposed to set input mode to binary at the start of the program). To test, I'm resetting the program after each use and renaming the text files so they are all tested with the same name. I'm using C:/Users/User/Desktop/file.txt as my DOS command.
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
int main(void){
int s1=0, s2=0, s3=0, s4=0;
int m1=3, m2=7, m3=13, m4=23;
int B;
_setmode(_fileno(stdin), _O_BINARY);
while((B=getchar()) != EOF)
{
s1 = (s1 + B*m1) % 256;
s2 = (s1+s2 + B*m2) % 256;
s3 = (s1+s2+s3 + B*m3) % 256;
s4 = (s1+s2+s3+s4 + B*m4) % 256;
B = getchar();
printf("%02x%02x%02x%02x\n", s1, s2, s3, s4 );
}
return 0;
}
Files I'm using (pastebin with pastebin links to files since I need more rep to post more than 2 links):
File Links: http://pastebin.com/wLF9NRNu
I also just found out that I'm apparently only supposed to be checking the midpoint value, so I was given the following command, which seems more or less useless to me:
C:\ > mdPoint < file.txt
Also after playing with it some more, it seems my commands aren't opening the files at all and is just giving me output based on the command text I enter. Not sure what's up with that.