i wrote a code with c, that reads from 2 files, and than i compare the 2 buffers with strcmp. for some strings, even when i read from the exact same file, strcmp returns !=0
anybody has an idea why?
here is the relevent part from the code:
read_max[0]= read(fdin[0],read_buf,read_offset) ;
read_max[1]=read(fdin[1],read_buf2,read_offset);
if(strcmp(read_buf,read_buf2)){
same=1;
}
i tried to check for answers on this forum and in others, but the only answer i found was for the case of '\n' that is added. as i wrote in the headline, the problem isnwt that it doesn't get inside the if, but that it does( because it doesn't return 0)! its not the case here. the way of writing the strings are the same. in edition, sometimes strcmp works properly.
for example, if the file starts with whitespace or \n, it goes wrong. thank you!