I am new to C and recently ran into some trouble with mismatching data types and their memory allocation. I am writing a very simple program to calculate the xor checksum of a file read using Linux system calls.
My question is this: Do I need to be concerned with unpredictable results when comparing an off_t or ssize_t with a long or int?
For example:
long i;
for(i = 0; i < fileStat.st_size; i++)
{
// do stuff
}
and also:
ssize_t i;
for(i = 0; i < fileStat.st_size; i++)
{
// do stuff
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…