no, your not going to reduce memory utilization like I said without writing 
your own class, or just using char*.
My test shows that a string is 4 bytes, which is probably just the pointer. I 
thought there was more data stored there origenally.
#include <iostream>
#include <string>
using namespace std;

int main(void)
{
string i="hello";
cout << sizeof(i) << endl;
return 0;
}
so your just getting an extra four bytes over what you would get if you were to 
use char*.

  ----- Original Message ----- 
  From: anju chandran 
  To: [email protected] 
  Sent: Wednesday, February 04, 2009 9:43 AM
  Subject: Re: Re: [c-prog] memory utilisation by string variables


   in a particular c++ program string variables are used to store data loaded 
from database,is there any way to use string variable itself,without using 
char* or character array,is there any way to reduce memory utilisation by 
string variable ,hoping that i made the problem clear to all,please reply

  On Wed, 04 Feb 2009 Tyler Littlefield wrote :
  >I'm not totally sure what your asking.
  >The string class contains other fields that are part of that class that will 
add to the size.
  >If you want a more robust and compact string you'll have to write a class 
yourself or use char*.
  >
  > ----- Original Message -----
  > From: anju chandran
  > To: [email protected]
  > Sent: Wednesday, February 04, 2009 8:42 AM
  > Subject: [c-prog] memory utilisation by string variables
  >
  >
  >
  > hi all,
  >
  > it has been noticed that string variable is taking more memory than 
character array in a particular C++ program ,is there any way to use string 
variable itself without using character array,consuming less memory ,tried with 
string functions like resize and reserve,but no use,please help
  >
  > in anticipation
  >
  >
  > [Non-text portions of this message have been removed]
  >
  >
  >
  >
  >
  >[Non-text portions of this message have been removed]
  >

  [Non-text portions of this message have been removed]



   

[Non-text portions of this message have been removed]

Reply via email to