|
-
Dec 11th, 2003, 10:52 PM
#1
Thread Starter
Hyperactive Member
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
-
Dec 11th, 2003, 11:42 PM
#2
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.
-
Dec 12th, 2003, 01:05 AM
#3
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.
-
Dec 13th, 2003, 10:08 AM
#4
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.
-
Dec 13th, 2003, 02:16 PM
#5
Hyperactive Member
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
-
Dec 13th, 2003, 09:46 PM
#6
Thread Starter
Hyperactive Member
Thanks guys for the responce!
C¤ry Sanchez
Computer Science/Engineering
@ Penn State
IBM.zSeries Intern
Mandriva 2007
-
Dec 14th, 2003, 06:48 AM
#7
Hyperactive Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|