user1478983
user1478983

Reputation: 95

How to determine the size of a text file from its content

Let's say a text file contains the following text:

1.11111111
2.22222222
3.33333333
4.44444444
5.55555555

What would be size of the file? And how can we determine it?

Hypothesis: [5*(10 bytes for ten characters on each line) + 5 null pointers at the end of each string] = 55 bytes.

But windows is showing me 3 extra bytes, total 58 bytes. Where do the 3 bytes come from?

EDIT: NULL pointers take zero bytes. So, we have 8 extra bytes from somewhere.

More EDIT: After some experimenting, each time we press ENTER we create 2 bytes. That's where the 8 bytes came from- from pressing ENTER 4 times. What are these bytes called in programming terms?

Upvotes: 1

Views: 1088

Answers (1)

user983302
user983302

Reputation: 1437

\n and \r in end of each line except the last take 1 byte respectively.

Upvotes: 1

Related Questions