Hi, trying to teach myself c++ by basically finding working code for things I need and then breaking it down. For this I am currently just using a console application on windows using visual studio. I am determining filesize of MKV files which is working fine using this code:
// obtaining file size
constchar * filename = "test.mkv";
int main ()
ifstream file (filename, ios::in|ios::binary);
l = file.tellg();
file.seekg (0, ios::end);
m = file.tellg();
cout << "size of the MKV is ";
cout << " is " << (m-l) << " bytes.\n";
The code I found was using long variable for l+m but for MKV files which are alot bigger than random files this may be used for I used a double. I have a couple of questions, how can I display in KB do I just use (m-1 / 1024)? if this is the case how do I write the expression in c++ ?
I would then also like to be able to list all files within a folder and then say the file size next to them so instead of a global variable declaring the specific file I can just specify a folder name and then list everything in that with specific file sizes.
Any suggestions are welcome, and please remember I really am the definition of beginner so any pasted code please dont make the assumption I will have a clue what any of it does :)