I think the best way is to open the file in binary using fread(). Of course you'll need to use rand() to generate a random number (or an array if you want to make a longer *password*). Make sure you put the settings for fread() right, reading a specific number of blocks, each with sizeof(int) bytes. Then compare each two corresponding integers using the ^ operator and obviously save the result (probably in another file).
I know two ways to compare the right two integers. One obvious way is to loop through the clear text and cypher, and test whether you reached the end of the password to reset it. Something like this:
I wrote this fast so don't depend on it
for (i=0; i < cleartext_length; i++)
if (j == password_length) j=0;
cyphertext[i] = cleartext[i] ^ password[j++];
Another way is to divide the clear text length by the password length, then loop between them like this (you'll need the remainder too):
Again, I wrote these in a rush so don't depend on them.
div = cleartext_length / cypher_length;
for (i=0; i < div; i++)
for (j=0; j < cypher_length; j++)
cyphertext[i*cypher_length+j] = cleartext[i*cypher_length+j] ^ cypher[j];
mod = cleartext_length % cypher_length;
for (j=0; j < mod; j++)
cyphertext[cleartext_length-mod+j] = cleartext[cleartext_length-mod+j] ^ cypher[j];