Click to See Complete Forum and Search --> : Strings?
The Hobo
Jul 31st, 2002, 03:23 PM
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.
SteveCRM
Jul 31st, 2002, 04:39 PM
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
SteveCRM
Jul 31st, 2002, 04:39 PM
basically they are just easier to handle
The Hobo
Jul 31st, 2002, 05:08 PM
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?
nabeels786
Jul 31st, 2002, 05:16 PM
nope
string.h is basically just the same as char*, they've just made it easier to use
abdul
Jul 31st, 2002, 05:50 PM
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.
Wynd
Jul 31st, 2002, 05:51 PM
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.
abdul
Jul 31st, 2002, 05:59 PM
Oh ya, I meant <string>, not <string.h>.
The Hobo
Jul 31st, 2002, 08:32 PM
Thanks for all the help.
I always use <string> but I thought it was the same as <string.h> News to me :)
abdul
Jul 31st, 2002, 10:58 PM
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.html#SECTION001900000000000000000
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.