-
April 9th, 2010, 11:58 AM
#1
String in c++
I was storing a lot of things into my string, and it seems to have run out of memory. I have thought about using a array/vector of characters, however, I wish to retain the ability to do substring, and to read from a file into it. It is possible to read from a file into an array of characters (as in is there a method to do it?). If not, is there some sort of data storage that won't run out of memory, or dynamically changes size? (I hope that made sense. In short, I am running out of memory in my string and want an alternative)
Thanks in advance
-
April 9th, 2010, 12:06 PM
#2
Re: String in c++
I think you are looking for std::string, here is a simple tutorial:
http://www.codeguru.com/cpp/cpp/stri...cle.php/c13267
-
April 9th, 2010, 12:45 PM
#3
Re: String in c++
Is it possible to increase the max size of a string?
-
April 9th, 2010, 01:07 PM
#4
Re: String in c++
A std::string's size is limited only by available memory. Unless you have a string over a billion characters long, that isn't your trouble.
-
April 9th, 2010, 01:14 PM
#5
Re: String in c++
What makes you think you're running out of memory in your string?
-
April 9th, 2010, 05:55 PM
#6
Re: String in c++
If you have a string that's taking over 4GB of RAM, then I would rethink your program design. I can think of very few reasons that you would require a string that big, and if you are unfamiliar with std::string, I don't think that you're using it for one of those reasons.
-
April 11th, 2010, 02:37 PM
#7
Re: String in c++
If you are using big text files (or where else do you use such a big string?) then it is better to read them by small parts or start using file mapping.
You never know how big a file may be, so try to always work with parts of a file, not the whole.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|