Results 1 to 10 of 10

Thread: Strings?

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    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.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  2. #2
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    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

  3. #3
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    basically they are just easier to handle

  4. #4

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    nope

    string.h is basically just the same as char*, they've just made it easier to use
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  6. #6
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    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.
    Baaaaaaaaah

  7. #7
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    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.
    Alcohol & calculus don't mix.
    Never drink & derive.

  8. #8
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Oh ya, I meant <string>, not <string.h>.
    Baaaaaaaaah

  9. #9

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Thanks for all the help.

    I always use <string> but I thought it was the same as <string.h> News to me
    My evil laugh has a squeak in it.

    kristopherwilson.com

  10. #10
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    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
    Baaaaaaaaah

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