-
Strings?
What's the advantages/disadvantages of using string.h strings over char[] strings?
Basically, what is your opinions on strings? What kind is what? I know there's others than those two, and I don't even know the technical names for them. But I wish to learn about strings.
-
I like apstrings...other people hate them, but they were what I was taught. Instead of sayinig
char mywords[200];
char word1[20];
char word2[20];
strcat(mywords, word1);
strcat(mywords, word2);
you can just say
apstring mywords;
apstring word1;
apstring word2;
mywords = word1 + word2
apstring (i think string.h too) is much more like VB strings
-
basically they are just easier to handle
-
I really never saw the difference between string and apstring. Our instructor last year made us use apstring because that's what the book said to use and he didn't know any C++.
So I'm not being a bad or lazy programmer by using string.h for my strings?
-
nope
string.h is basically just the same as char*, they've just made it easier to use
-
string.h is pretty easier to use and it handles all the memory related stuff. Combining/searching/manipulating strings is pretty easy using "string". The only drawback of using "string" is that it won't work in C.
-
One thing though, <string> (the STL string class) is not the same as <string.h> (the non-standard version of <cstring> - strcat(), strcpy(), etc) are two different things. The STL strings are MUCH easier to use though.
-
Oh ya, I meant <string>, not <string.h>.
-
Thanks for all the help.
I always use <string> but I thought it was the same as <string.h> News to me :)
-
Ya, <string.h> is C-style but <string> is from STL. If you want some information on how it is then you can this page:
http://www.cs.cf.ac.uk/Dave/C/node19...00000000000000