I defined an array:
char arr [1480];
Now I read exactly 1480 characters from the file and placed it in arr (making arr [i] = c). I know 1480 characters because I use a while loop to read one char ar time (istream.get ()) and stops when incremental index = 1480.
However, after that, I make strlen (an array) and it returns 1512. How did it happen? This only happens in some cases, but not in all cases, although every time I read from a file, I always read up to 1480 characters.
My doubt is that a single char can take more than 1 units (units returned by strlen (arr)). If so, how can I fix this?
thank
PS: I used to ask a problem that my pointer is getting garbage, and this is the reason when I have a buffer (arr) of length> 1480.
source
share