I am triing to save a .txt file into an object(c++). the problem is i dont know how big it is.
in c i would do it with a evl with the malloc() function but i have no idea how to do that in c++ or how to google that issue =/
I am triing to save a .txt file into an object(c++). the problem is i dont know how big it is.
in c i would do it with a evl with the malloc() function but i have no idea how to do that in c++ or how to google that issue =/
Why not use std::ostringstream?
Or if you want to use an equivalent to malloc, use:
char *storage = new char[__size__];
....
delete[] storage;
But if your file is a binary file odds are you have a byte which is null. strlen won't work the way you expect it then.
You can also use std::string, std::vector<char> in which you can have any values and that can be converted to const char * easily.
You can use the new operator in C++, or better yet one of the standard library containers.