You're trying to store some data in the memory location pointed to by the pointer line. Where does that pointer point? There's no way to know, because you never gave it a value; it's pointing into some random piece of memory somewhere, and the operating system then sees you trying to write over memory that isn't yours and stops you.
If you're going to write into the memory that line points to, you've got to actually ensure that it points somewhere sensible.
Thanks a lot ESS. that compressing it is awesome and I should have seen that. About the char *line. I was under the assumption you could use that as a string pointer. Thank moschops. I will try to work it out.
About the char *line. I was under the assumption you could use that as a string pointer.
A C++ (std) string isn't unlimited. But when you add some new content, its buffer size increases to allow you more space to put chars into. So, if you want a std::string with 512 bytes of buffer, you should push at least 512 characters into a string. Otherwise, the string's buffer size is less than 512, it's a dynamic buffer.
Let's say this:
1 2 3 4 5 6
string EmptyString; // EmptyString does not need any memory at this point.
//It will probably allocate one byte for the default null-terminator.
//EmptyString's char pointer at this point of time points to AT LEAST one byte of memory.
EmptyString >> "Text"; // Now, the string needs some more memory.
//So it allocates other 4 characters, and copies the old 1-byte buffer into the new 5-byte buffer.
//Now EmptyString's char pointer at this point of time points to AT LEAST five bytes of memory.