Results 1 to 7 of 7

Thread: I thought the strlen, strcpy, and strcmp are in the <cstring> ... .:Resolved:.

  1. #1

    Thread Starter
    Hyperactive Member voidflux's Avatar
    Join Date
    Jun 2003
    Location
    Brockway, PA
    Posts
    290

    I thought the strlen, strcpy, and strcmp are in the <cstring> ... .:Resolved:.

    Hello everyone!
    I was wondering, does the <string> lib contain the <cstring> functions as well?
    I've used the c-style string functions by #include <string> without any errors, but I always thought they were located in the <cstring> because thats what the books usually tell you. Any idea's? The reason i'm asking little stupid questions, is because i'm having a final and he'll be anal about everything and i don't feel like missing an easy question!
    Last edited by voidflux; Dec 13th, 2003 at 09:47 PM.
    C¤ry Sanchez
    Computer Science/Engineering
    @ Penn State
    IBM.zSeries Intern
    Mandriva 2007

  2. #2
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    If you use a CString, include <cstring>. If you are going to use an std::string include <string>.

    The strings are different, but the function names and the way they are used may be the same/similar.

  3. #3
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403
    It's probably because the std::string class uses the c-style functions internally to deal with the buffer, so <string> includes <cstring>. Regardless, include <string> if you're using std::string, include <cstring> if you're using strcpy/strcat, and theres no harm in including both if you use both.
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    To take this further: your <string> probably includes <cstring>, but that doesn't mean any other <string> (other compilers) includes <cstring>.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5
    Hyperactive Member sw_is_great's Avatar
    Join Date
    Nov 2003
    Posts
    330
    i am not sure but i think in hp unix or sun solaris , u find strlen in stdio.h or stdlib.h-----


    should follow , always the ANSI, so that there is no probs while porting
    Regards

  6. #6

    Thread Starter
    Hyperactive Member voidflux's Avatar
    Join Date
    Jun 2003
    Location
    Brockway, PA
    Posts
    290
    Thanks guys for the responce!
    C¤ry Sanchez
    Computer Science/Engineering
    @ Penn State
    IBM.zSeries Intern
    Mandriva 2007

  7. #7
    Hyperactive Member sw_is_great's Avatar
    Join Date
    Nov 2003
    Posts
    330
    Regards

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width