You must have some other problem elsewhere...
This code shows how you can build a big char buffer (5000 chars) and safely
assign it to a STL string:
<code>
#include <iostream>
#include <string>
using std::string;
using std::cout;
using std::endl;
int main()
{
//
// Allocate a big buffer of char's and fill it with 'x's
//
const int len = 5000;
char * bigString = new char[len];
for (int i = 0; i < (len-1); i++)
{
bigString[i] = 'x';
}
bigString[len - 1] = '\0';
//
// Copy to a STL std::string
//
string s = bigString;
// Print
cout << s.c_str() << endl;
// Cleanup
delete [] bigString;
return 0;
}
</code>
Giovanni
For example, make sure that you put an end of string ('\0') at the end of
your buffer...
Giovanni
sachin:
Maximum length of std::string is one less than the maximum value of the size_t
type, which is 2^32 (2^64 on 64 bit systems).
Use std::string::max_size() to check.
--
David Wilkinson
Visual C++ MVP
thansks