I'm using a 'STRING' variable to store the entire contents of a file. Is there any possibility of buffer overflow if the content of the file is large? (eg: say size of the file is 30MB).
Thanks in advance
Yes, thank you AD for the clarification. I saw a developer mention a max size of the std::string class but didn't really investigate sources until recently. Here's some more information.
Edit: Depending on what a kilo-byte, etc means these days, you'll be in reasonable hands if you pull a 30 MB file into a string.
For example, if a megabyte is 1024 kilobytes and a kilobyte is 1024 bytes, and each char is a byte (which, a standard char should be) then you are looking at 30 * 1024 * 1024 bytes of information, which is only 251658240 bytes which is far under the limit of a string object.
If MB means 1000 kilobytes and a kilobytes is 1000 bytes, you're looking at a slightly smaller number than the one mentioned.
To be safe, assume 1024 for every additional "step" in bytes.