Real length of a char string?
The length of a character string is usually identified by the first null byte. But what if you had read a binary file? Files are filled with null bytes. I know fread returns the amount of bytes read, but is there another way?
So strlen("123456") returns 6;
strlen("123456\07"), that is 1,2,3,4,5,6,NULLBYTE,7, and that returns 6. Any otehr way?
Re: Real length of a char string?
If your main concern is binary files there are usually platform specific APIs for counting the length of files.. which are basically strlen that ignores null bytes.
You could probably find a function on the internet with little trouble that counts strings without looking for a null byte.
chem
Re: Real length of a char string?
So you mean basically the length of the file? Look up fseek() and ftell().
Re: Real length of a char string?
No, I just used that as an example.
Re: Real length of a char string?
Then the answer to your question is implementation-specific and you'll have to do some research.