Thread: edit header file

  1. #1
    Registered User
    Join Date
    Feb 2002

    edit header file


    Would anyone know how to avoid using c_str() when reading
    text from a file?

    Thank You,


  2. #2
    If we are talking about the same thing, c_str() is the member function (method) of the class string. The function is to get the pointer to a c-like string or in other words a character array termintated by the null character. c_str() can be used for retrieval purposes but not modification.


    string s;
    char buffer[80];

    s = "what's up people";

    strcpy(buffer, s.c_str() );

    to copy into it instead you would do this...

    buffer[1000] = {"lskfjlsjflsdlfslf"};

    string s;

    s = buffer;

    const E *c_str() const;
    The member function returns a pointer to a nonmodifiable C string constructed by adding a terminating null element (E(0)) to the controlled sequence. Calling any non-const member function for *this can invalidate the pointer.


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM
  5. header file compile error
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 02-23-2002, 06:28 AM