Kwizatz, you are overflowing your "szBuffer" if the string is bigger than 1024 char''s. Anytime you use static fixed-length buffers like that with unbounded-length data you''re probably opening yourself up to an overflow.
Julio, I don''t know where you''re getting "each line can be a max of 255", but''s it''s not true in general. A standard null terminated C string can be as big as you want it to be regardless of whether it''s in memory or in a file.
-Mike
Reading strings of unknown size-how?
Mike, you are right on the overflow, now that I think about it, so, may not be a good Idea after all, only if you are confident the strings wont be bigger than your buffer. Thanks for pointing it out.
Julio, MAX_PATH which is the constant size for maximum path/filename lenght is 255 I believe in windows9x (not sure about NT/2000) so thats probably where you are mistaken, this means a string that contains a path to a file cannot be more than 255, doesnt mean you cant have strings bigger.
if the string you save in your file is meant to be a path then just replace 1024 in my code above with MAX_PATH and unless someone deliverately changes the file path to contain more chars, overflowing may not be an issue.
Julio, MAX_PATH which is the constant size for maximum path/filename lenght is 255 I believe in windows9x (not sure about NT/2000) so thats probably where you are mistaken, this means a string that contains a path to a file cannot be more than 255, doesnt mean you cant have strings bigger.
if the string you save in your file is meant to be a path then just replace 1024 in my code above with MAX_PATH and unless someone deliverately changes the file path to contain more chars, overflowing may not be an issue.

My implementation won''t overflow, becuase it always reads BufferSize chars, and looks for the first null terminator in there. If it finds one, it backs up the file pointer to the character after it, otherwise, it reads again.
There, a 1 paragraph explanation of my algorithm.
-- Succinct(Don't listen to me)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement