string class :: how to get char* from a string object

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
  I have two question. 
  1) What will be the best way to get char * from a string. Whether this is a good option?
  string str("abcdef");
  char * cstr = const_cast<char *> str.c_str() ; 
    Problem is that, then user can modify the cstr which in turn modify the str object. That is not desirable. 

  2) If i do the following ::
   string str("abcdef");
  Whether string class will append a '\0' after storing the 'abcdef' or not ?
  What will be the capacity of the above string object ? Why it is not the same as no. of character of "abcdef" ?

  Thanking you,
  Jyotirmoy Das
jyotirmoy_das@xxxxxxxxxxx
  


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux