How to calculate the files size. | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 18

How to calculate the files size.

Let's say I'm going to create a certain file with a certain amount of content. How can I calculate the size of the file before creating it? The content will be plain text so is the file size just the amount of bytes the text has?

18th May 2018, 11:09 PM
Toni Isotalo
Toni Isotalo - avatar
2 Respuestas
+ 5
May be it is related to the character encoding we like to use in our text file.. If it is on ASCII, each character takes one byte or less so that we can calculate the file size.. If it is on UNICODE, the file size varies.. for more information refer this stack overflow post https://stackoverflow.com/questions/5290182/how-many-bytes-does-one-unicode-character-take
19th May 2018, 10:37 AM
Ravikumar R
Ravikumar R - avatar
+ 1
Hello Toni! See the c++ lesson, and look the foolowing topic"sizeof an Array" they talk about the sizeof () function. Remind : this Array category type minimum size boolean bool 1 byte character char 1 byte integer int 2 bytes and so on Good luck!! stephan (France)
29th May 2018, 6:14 PM
soules