Thread: string::append

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    164

    string::append

    Is there a similar function like string::append in cstring lib???? for c-style strings (char*) ???

  2. #2
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    strcat() and strncat(). Google them. They should be in string.h

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    164
    k ty

  4. #4
    Registered User
    Join Date
    Nov 2007
    Posts
    164
    any function which converts an integer into string ???
    i know of itoa() but its non-standard any other????? trick ?? way ??? help or hint plzzz
    Last edited by manzoor; 10-29-2008 at 08:05 AM.

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    sprintf()?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #6
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    You could add '0' to each number and convert it to a string.

  7. #7
    Amazingly beautiful user.
    Join Date
    Jul 2005
    Location
    If you knew I'd have to kill you
    Posts
    254
    You could use a string stream

    Code:
    #include <sstream>
    #include <iostream>
    
    using namespace std;
    int main(int argc, char **argv)
    {
      char myString[] = "342";
      stringstream s;
      int a;
     
      s << myString;
      s >> a;
     
      cout << a << endl;
    }
    Note using stringstreams, you can convert strings to numbers, numbers to strings, or anything to anything that streams have operator<< and operator>> for.
    Programming Your Mom. http://www.dandongs.com/

Popular pages Recent additions subscribe to a feed