Hi, I need a bit of help with this function...
What I'm trying to do is call the function with a string, XOR it with value 255 and save it to the file. If I put a value of 0 to the XOR (leave as is) then it works properly, but if I put any value to XOR the original value with, then it doesn't work: it saves the previous XORed string constantly. Why could it be? I tried cleaning the "string" variable with "string = 0" and "string[0] = 0" but it does the same. Any clues?
Here is the code:
void write(char string[])
{
int i;
FILE *file;
file=fopen("log.txt","ab+");
if(file!=NULL)
{
for(i=0;i<strlen(string);i++)
string[i]^=255;
fputs(string,file);
}
fflush(file);
fclose(file);
}
Many thanks in advance!